示例#1
0
def create_installer(args, cat_info, env_info, module_names):
    """
    Overwrite a staging subtree of the current directory.
    The idea it to tgz this directory and send it to the target server.
    On the target server it should be unzipped and extracted,
    and the installer script should put everything in the correct
    prespecified directories.
    """
    # define the local staging directory
    stage = args.make_installer
    # remove the old staging directory if it exists
    if os.path.isdir(stage):
        shutil.rmtree(stage)
    # create some directories
    os.makedirs(os.path.join(stage, 'python-files'))
    os.makedirs(os.path.join(stage, 'xml-files'))
    # add the appropriate python files and the const data
    meta.add_python_files(module_names, os.path.join(stage, 'python-files'))
    # create the xml files
    identifiers, import_errors = mobyle.add_xml_files(
            cat_info, env_info,
            module_names, args.short_length,
            os.path.join(stage, 'xml-files'),
            args.runbsub)
    for e in import_errors:
        print e
    # copy the installer script
    shutil.copy('install-mob-tools.py',
            os.path.join(stage, 'install-mob-tools.py'))
    # copy the installer script dependency
    shutil.copy('mobenv.py',
            os.path.join(stage, 'mobenv.py'))
    # create the installer configuration
    with open(os.path.join(stage, 'install-mob-tools.conf'), 'w') as fout:
        print >> fout, '#', ' '.join(sys.argv)
        print >> fout, '\t'.join(['auto_path', env_info.auto_path])
        print >> fout, '\t'.join(['python_path', env_info.python_path])
        print >> fout, '\t'.join(['mob_core', env_info.mob_core])
        print >> fout, '\t'.join(['mob_version', args.mobyle_version])
    # create a file with a fragment that could be added to the config
    with open(os.path.join(stage, 'sys.config.fragment'), 'w') as fout:
        print >> fout, '# begin autogenerated code'
        print >> fout, 'my_pca_names = ['
        for ident in sorted(identifiers):
            print >> fout, "\t\t'%s'," % ident
        print >> fout, "\t\t]"
        dstring = "dict((x, 'Sys') for x in my_pca_names)"
        print >> fout, 'PARTICULAR_BATCH.update(%s)' % dstring
        print >> fout, '# end autogenerated code'
    # use subprocess instead of tarfile to create the tgz
    cmd = ['tar', 'czvf', stage + '.tgz', stage]
    subprocess.call(cmd)
示例#2
0
def create_installer(args, cat_info, env_info, module_names):
    """
    Overwrite a staging subtree of the current directory.
    The idea it to tgz this directory and send it to the target server.
    On the target server it should be unzipped and extracted,
    and the installer script should put everything in the correct
    prespecified directories.
    """
    # define the local staging directory
    stage = args.make_installer
    # remove the old staging directory if it exists
    if os.path.isdir(stage):
        shutil.rmtree(stage)
    # create some directories
    os.makedirs(os.path.join(stage, 'python-files'))
    os.makedirs(os.path.join(stage, 'xml-files'))
    # add the appropriate python files and the const data
    meta.add_python_files(module_names, os.path.join(stage, 'python-files'))
    # create the xml files
    identifiers, import_errors = mobyle.add_xml_files(
        cat_info, env_info, module_names, args.short_length,
        os.path.join(stage, 'xml-files'), args.runbsub)
    for e in import_errors:
        print e
    # copy the installer script
    shutil.copy('install-mob-tools.py',
                os.path.join(stage, 'install-mob-tools.py'))
    # copy the installer script dependency
    shutil.copy('mobenv.py', os.path.join(stage, 'mobenv.py'))
    # create the installer configuration
    with open(os.path.join(stage, 'install-mob-tools.conf'), 'w') as fout:
        print >> fout, '#', ' '.join(sys.argv)
        print >> fout, '\t'.join(['auto_path', env_info.auto_path])
        print >> fout, '\t'.join(['python_path', env_info.python_path])
        print >> fout, '\t'.join(['mob_core', env_info.mob_core])
        print >> fout, '\t'.join(['mob_version', args.mobyle_version])
    # create a file with a fragment that could be added to the config
    with open(os.path.join(stage, 'sys.config.fragment'), 'w') as fout:
        print >> fout, '# begin autogenerated code'
        print >> fout, 'my_pca_names = ['
        for ident in sorted(identifiers):
            print >> fout, "\t\t'%s'," % ident
        print >> fout, "\t\t]"
        dstring = "dict((x, 'Sys') for x in my_pca_names)"
        print >> fout, 'PARTICULAR_BATCH.update(%s)' % dstring
        print >> fout, '# end autogenerated code'
    # use subprocess instead of tarfile to create the tgz
    cmd = ['tar', 'czvf', stage + '.tgz', stage]
    subprocess.call(cmd)
示例#3
0
def main(args):
    if bool(args.manifest) == bool(args.create_all):
        raise ValueError('expected exactly one of {manifest, create_all}')
    if args.manifest:
        with open(args.manifest) as fin:
            module_names = [x.strip() for x in fin]
    if args.create_all:
        module_names = []
        for name in os.listdir('.'):
            if re.match(r'^\d{8}[a-zA-Z]\.py$', name):
                module_name = name[:-3]
                module_names.append(module_name)
    import_errors = mobyle.add_xml_files(module_names, args.auto, args.target,
                                         args.short_length)
    print 'import errors:'
    for e in import_errors:
        print e
示例#4
0
def main(args):
    if bool(args.manifest) == bool(args.create_all):
        raise ValueError('expected exactly one of {manifest, create_all}')
    if args.manifest:
        with open(args.manifest) as fin:
            module_names = [x.strip() for x in fin]
    if args.create_all:
        module_names = []
        for name in os.listdir('.'):
            if re.match(r'^\d{8}[a-zA-Z]\.py$', name):
                module_name = name[:-3]
                module_names.append(module_name)
    import_errors = mobyle.add_xml_files(
            module_names, args.auto, args.target, args.short_length)
    print 'import errors:'
    for e in import_errors:
        print e
示例#5
0
def main(args):
    # check for flag conflicts
    if args.deploy and args.make_installer:
        raise ValueError(
            'the "deploy" and "make_installer" flags are incompatible')
    # initialize the mobyle category information
    cat_info = mobyle.CategoryInfo(args.show_io_types, args.show_tags,
                                   args.universal_category)
    # get the module names
    module_names = meta.get_module_names(args.manifest, args.create_all,
                                         args.create_tagged)
    # define the environment on the target server
    auto_path = os.path.join(args.target, 'auto.py')
    env_info = mobenv.create_environment_info(auto_path, args.python_path,
                                              args.mobyle_core,
                                              args.mobyle_version)
    if args.make_installer:
        create_installer(args, cat_info, env_info, module_names)
    else:
        # create the python subtree
        meta.add_python_files(module_names, args.target)
        # create the mobyle xml interface files
        import_errors = mobyle.add_xml_files(cat_info, env_info, module_names,
                                             args.short_length,
                                             env_info.get_xml_dir(),
                                             args.runbsub)
        for e in import_errors:
            print e
    if args.clean:
        cmd = env_info.get_clean_command()
        subprocess.call(cmd)
    if args.index:
        cmd = env_info.get_index_command()
        subprocess.call(cmd)
    if args.deploy:
        cmd = env_info.get_deploy_command()
        subprocess.call(cmd)
示例#6
0
def main(args):
    # check for flag conflicts
    if args.deploy and args.make_installer:
        raise ValueError(
                'the "deploy" and "make_installer" flags are incompatible')
    # initialize the mobyle category information
    cat_info = mobyle.CategoryInfo(
            args.show_io_types, args.show_tags, args.universal_category)
    # get the module names
    module_names = meta.get_module_names(
            args.manifest, args.create_all, args.create_tagged)
    # define the environment on the target server
    auto_path = os.path.join(args.target, 'auto.py')
    env_info = mobenv.create_environment_info(
            auto_path, args.python_path,
            args.mobyle_core, args.mobyle_version)
    if args.make_installer:
        create_installer(args, cat_info, env_info, module_names)
    else:
        # create the python subtree
        meta.add_python_files(module_names, args.target)
        # create the mobyle xml interface files
        import_errors = mobyle.add_xml_files(
                cat_info, env_info,
                module_names, args.short_length, env_info.get_xml_dir(),
                args.runbsub)
        for e in import_errors:
            print e
    if args.clean:
        cmd = env_info.get_clean_command()
        subprocess.call(cmd)
    if args.index:
        cmd = env_info.get_index_command()
        subprocess.call(cmd)
    if args.deploy:
        cmd = env_info.get_deploy_command()
        subprocess.call(cmd)