PageRenderTime 31ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/galaxy/sample_tracking/data_transfer.py

https://bitbucket.org/cistrome/cistrome-harvard/
Python | 49 lines | 37 code | 5 blank | 7 comment | 4 complexity | 7c378da389d729ae8e5568634e147072 MD5 | raw file
  1. import logging, sys
  2. class DataTransferFactory( object ):
  3. type = None
  4. def parse( self ):
  5. pass
  6. class ScpDataTransferFactory( DataTransferFactory ):
  7. type = 'scp'
  8. def __init__( self ):
  9. pass
  10. def parse( self, config_file, elem ):
  11. self.config = {}
  12. # TODO: The 'automatic_transfer' setting is for future use. If set to True, we will need to
  13. # ensure the sample has an associated destination data library before it moves to a certain state
  14. # ( e.g., Run started ).
  15. self.config[ 'automatic_transfer' ] = elem.get( 'automatic_transfer' )
  16. self.config[ 'host' ] = elem.get( 'host' )
  17. self.config[ 'user_name' ] = elem.get( 'user_name' )
  18. self.config[ 'password' ] = elem.get( 'password' )
  19. self.config[ 'data_location' ] = elem.get( 'data_location' )
  20. # 'rename_dataset' is optional and it may not be defined in all external types
  21. # It is only used is AB SOLiD external service type for now
  22. rename_dataset = elem.get( 'rename_dataset', None )
  23. if rename_dataset:
  24. self.config['rename_dataset'] = rename_dataset
  25. # Validate
  26. for name, value in self.config.items():
  27. assert value, "'%s' attribute missing in 'data_transfer' element of type 'scp' in external_service_type xml config file: '%s'." % ( name, config_file )
  28. class HttpDataTransferFactory( DataTransferFactory ):
  29. type = 'http'
  30. def __init__( self ):
  31. pass
  32. def parse( self, config_file, elem ):
  33. self.config = {}
  34. self.config[ 'automatic_transfer' ] = elem.get( 'automatic_transfer' )
  35. # Validate
  36. for name, value in self.config.items():
  37. assert value, "'%s' attribute missing in 'data_transfer' element of type 'http' in external_service_type xml config file: '%s'." % ( name, config_file )
  38. class FtpDataTransferFactory( DataTransferFactory ):
  39. type = 'ftp'
  40. def __init__( self ):
  41. pass
  42. def parse( self, elem ):
  43. pass
  44. data_transfer_factories = dict( [ ( data_transfer.type, data_transfer() ) for data_transfer in [ ScpDataTransferFactory, HttpDataTransferFactory, FtpDataTransferFactory ] ] )