Esempio n. 1
0
def compose( the_scripts, the_script_args, the_sequence_file ) :
    import cloudflu.common as common
    
    a_compose = ""
    if the_scripts != None :
        a_compose += " --script-file='%s'" % common.print_args( the_scripts, common.arg_list_separator() )
        a_compose += " --script-args='%s'" % common.print_args( the_script_args, common.arg_list_separator() )
        pass
    
    if the_sequence_file != None :
        a_compose = " --sequence-file='%s'" % the_sequence_file
        pass

    return a_compose
def extract( the_option_parser ) :
    from cloudflu.common import print_d, print_i, print_e
    import os, os.path
    
    an_options, an_args = the_option_parser.parse_args()

    a_located_files = an_options.located_files
    if a_located_files != None :
        from cloudflu import common
        a_located_files = a_located_files.split( common.arg_list_separator() )
        pass

    print_d( "a_located_files = %s\n" % a_located_files )

    an_output_dir = an_options.output_dir
    print_d( "an_output_dir = '%s'\n" % an_output_dir )
    
    a_fresh = an_options.fresh
    print_d( "a_fresh = %s\n" % a_fresh )

    a_wait = an_options.wait
    print_d( "a_wait = %s\n" % a_wait )

    a_remove = an_options.remove
    print_d( "a_remove = %s\n" % a_remove )

    return a_located_files, an_output_dir, a_fresh, a_wait, a_remove
def compose( the_located_files, the_output_dir, the_fresh, the_wait, the_remove ) :
    a_compose = ''

    if the_output_dir != None :
        a_compose += " --output-dir='%s'" % the_output_dir
        pass

    if the_located_files != None :
        from cloudflu import common
        a_compose += " --located-files='%s'" % common.print_args( the_located_files, common.arg_list_separator() )
        pass

    if the_fresh == True :
        a_compose += " --fresh"
        pass
        
    if the_wait == True :
        a_compose += " --wait"
        pass
        
    if the_remove == True :
        a_compose += " --remove"
        pass
        
    return a_compose
def usage_description() :
    from cloudflu import common
    
    an_usage_description = ""
    an_usage_description += " --study-name=<my uploaded study>"
    an_usage_description += "[ --located-files='<file path 1>%s<file path 2>..']" % common.arg_list_separator()
    
    return an_usage_description
Esempio n. 5
0
def extract( the_option_parser ) :
    import cloudflu.common as common
    an_options, an_args = the_option_parser.parse_args()

    import os.path
    a_scripts = None
    a_script_args = None
    a_script_file = an_options.script_file
    if a_script_file != None :
        # First, check that all appointed scripts exists and regular files
        a_scripts = a_script_file.split( common.arg_list_separator() )
        for a_script in a_scripts :
            if not os.path.isfile( a_script ) :
                an_option_parser.error( "--script-file='%s' must be a file" % a_script )
                pass
            pass

        # Next, check wether number of 'scripts' match number of script's args
        if an_options.script_args != None :
            a_script_args = an_options.script_args.split( common.arg_list_separator() )
            if len( a_script_args ) != len( a_scripts ) :
                an_option_parser.error( "number of items in --script-file='%s'"
                                        " must the same or zero as for --script-args='%s' " 
                                        % ( a_script_files, an_options.script_args ) )
                pass
            pass
        else :
            a_script_args = [ "" for a_script in a_scripts ]
            pass
        pass

    a_sequence_file = an_options.sequence_file
    if a_sequence_file != None :
        a_sequence_file = os.path.abspath( a_sequence_file )
        if not os.path.isfile( a_sequence_file ) :
            an_option_parser.error( "--sequence-file='%s' must be a file" % a_sequence_file )
            pass
        pass

    return a_scripts, a_script_args, a_sequence_file
def extract( the_option_parser ) :
    from cloudflu.common import print_d
    an_options, an_args = the_option_parser.parse_args()

    a_located_files = an_options.located_files
    if a_located_files != None :
        from cloudflu import common
        a_located_files = a_located_files.split( common.arg_list_separator() )
        pass

    print_d( "a_located_files = %s\n" % a_located_files )

    return a_located_files
def extract( the_option_parser ) :
    from cloudflu.common import print_d, print_i, print_e
    
    an_options, an_args = the_option_parser.parse_args()

    from cloudflu.preferences import get_inputs
    a_source_files = get_inputs( an_args )
    print_d( "a_source_files = %s\n" % a_source_files )

    a_files = list()
    for a_file in a_source_files :
        import os.path
        if not os.path.exists( a_file ) :
            the_option_parser.error( "The given file ('%s') should exists\n" % a_file )
            pass
        a_files.append( os.path.abspath( a_file ) )
        pass
    
    if len( a_files ) == 0 :
        the_option_parser.error( "You should define one valid 'file' at least\n" )
        pass

    print_d( "a_files = %r\n" % a_files )
    
    from cloudflu import common
    a_file_locations = an_options.file_locations
    a_file_locations = a_file_locations.split( common.arg_list_separator() )

    a_file2locations = {}
    if len( a_file_locations ) > 1 :
        if len( a_files ) != len( a_file_locations ) :
            the_option_parser.error( "The amount of file locations shoudl be equal to the number of given files\n" )
            pass
        else :
            for an_id in range( len( a_files ) ) :
                a_file = a_files[ an_id ]
                a_location = a_file_locations[ an_id ]
                a_file2locations[ a_file ] = a_location
                pass
            pass
        pass
    else :
        a_location = a_file_locations[ 0 ]
        for a_file in a_files:
            a_file2locations[ a_file ] = a_location
            pass
        pass   
    
    print_d( "a_file2locations = %r\n" % a_file2locations )

    return a_file2locations
Esempio n. 8
0
def usage_description() :
    import cloudflu.common as common

    an_usage_description = ""
    an_usage_description += " [ --script-file='./remote_adjust_profile.sh%s./remote_update_sources-list.sh' ]" % common.arg_list_separator()
    an_usage_description += " [ --sequence-file='./remote_sshd-config.sh' ]"

    return an_usage_description
Esempio n. 9
0
    an_usage_description = ""
    an_usage_description += " [ --script-file='./remote_adjust_profile.sh%s./remote_update_sources-list.sh' ]" % common.arg_list_separator()
    an_usage_description += " [ --sequence-file='./remote_sshd-config.sh' ]"

    return an_usage_description


#--------------------------------------------------------------------------------------
from cloudflu.preferences import OptionGroup, PersistentOption, TransientOption
a_container = OptionGroup( 'common.ssh.run' )

import cloudflu.common as common
a_container.add_option( TransientOption( "--script-file",
                                         metavar = "< script (or list of scripts separated by '%s')"
                                         "or be executed on the remote host >" % common.arg_list_separator(),
                                         action = "store",
                                         dest = "script_file",
                                         default = None ) )

a_container.add_option( TransientOption( "--script-args",
                                         metavar = "< arguments (or list of arguments separated by '%s)"
                                         "or the remote script execution >" % common.arg_list_separator(),
                                         action = "store",
                                         dest = "script_args",
                                         default = None ) )

a_container.add_option( TransientOption( "--sequence-file",
                                         metavar = "< file with sequence of commands to be executed >",
                                         action = "store",
                                         dest = "sequence_file",
def usage_description() :
    from cloudflu import common

    an_usage_description = " --file-locations='< file1 location >%s< file2 location >..'" % common.arg_list_separator()
    an_usage_description += " < file 1 > < folder 2 > .."
    
    return an_usage_description
def compose( the_located_files ) :
    if the_located_files != None :
        from cloudflu import common
        return " --located-files='%s'" % common.print_args( the_located_files, common.arg_list_separator() )

    return ''