コード例 #1
0
 def getPellet(self):
     """I read Pellet's location from ../config/pellet.conf"""
     import ConfigParser
     config = ConfigParser.ConfigParser()
     config.readfp(open('config/pellet.conf'))
     for name, value in config.items("Pellet"):
         if name == 'pelletcmd':
             return value
コード例 #2
0
ファイル: builtins.py プロジェクト: AwelEshetu/cwm
 def getPellet(self):
     """I read Pellet's location from ../config/pellet.conf"""
     import ConfigParser
     config = ConfigParser.ConfigParser()
     config.readfp(open('config/pellet.conf'))
     for name, value in config.items("Pellet"):
         if name == 'pelletcmd':
             return value
コード例 #3
0
ファイル: commander.py プロジェクト: ironmissy/vmchecker
def main(dir):
    """Unpacks archive and invokes executor"""
    # reads assignment config
    with open(join(dir, 'config')) as handle:
        config = ConfigParser.RawConfigParser()
        config.readfp(handle)

    # reads vmchecker_storer.ini
    with open(join(dir, 'storer')) as handle:
        storer = ConfigParser.RawConfigParser()
        storer.readfp(handle)

    # copies files to where vmchecker expects them (wtf
    # XXX 'executor_jobs' path is hardcoded in executor

    ejobs = vmcheckerpaths.abspath('executor_jobs')
    # cleans up executor_jobs, if not already clean
    if isdir(ejobs):
        shutil.rmtree(ejobs)
    os.mkdir(ejobs)

    shutil.copy(        # copies assignment
        join(dir, 'archive.zip'),
        vmcheckerpaths.abspath('executor_jobs', 'file.zip'))
    shutil.copy(        # copies tests
        join(dir, 'tests.zip'),
        vmcheckerpaths.abspath('executor_jobs', 'tests.zip'))

    assignment = config.get('Assignment', 'Assignment')  # yet another hack
    section = assignments._SECTION_PREFIX + assignment

    machine = storer.get(section, 'Machine')
    timeout = storer.get(section, 'Timeout')
    kernel_messages = storer.get(section, 'KernelMessages')

    _run_executor(ejobs, machine, assignment, timeout, kernel_messages)

    try:
        _run_callback(dir, ejobs)
    except:
        _logger.exception('cannot run callback')

    # clears files
    shutil.rmtree(ejobs)

    _logger.info('all done')
コード例 #4
0
ファイル: swinelib.py プロジェクト: dswd/Swine
 def migrateOldConfig(self): #Legacy support code
   import ConfigParser, ast
   config = ConfigParser.ConfigParser()
   if os.path.exists(self.getOldConfigFile()):
     with codecs.open(self.getOldConfigFile(), "r", "utf8") as fp:
       config.readfp(fp)
   if not config.has_section("__SYSTEM__"):
     config.add_section("__SYSTEM__")
   self.settings = dict(config.items("__SYSTEM__"))
   for name in config.sections():
     if name != "__SYSTEM__":
       dat = dict(config.items(name))
       if dat["program"] and dat["program"].startswith("["):
         args = ast.literal_eval(dat["program"])
       else:
         args = shlex.split(str(dat["program"]))
       dat["program"] = args[0]
       if "\\\\" in dat["program"]:
         dat["program"] = ast.literal_eval('"'+dat["program"]+'"')
       dat["arguments"] = args[1:]
       self.shortcutData[name] = dat
コード例 #5
0
def main():
    """
    Method main, set output dir and call a specific function, as given in the options
    :param argv:
    :return: None
    """
    config = RawConfigParser()
    config.readfp(resource_stream('drf_gen', 'config.ini'))

    outputdir = config.get('outputdir', 'dir')
    os.mkdir(outputdir) if not os.path.exists(outputdir) else outputdir

    ap = ArgumentParser()
    ap.add_argument('-vv', '--verbose',
                    default=False,
                    help='Increase verbosity.')

    ap.add_argument('-m', '--model',
                    required=True,
                    action='store',
                    dest='models_path',
                    help='Path to your models.py file.')

    ap.add_argument('-a', '--admin',
                    action='store_true',
                    help='Will create a admin.py file from your models.py.')

    ap.add_argument('-v', '--views',
                    action='store_true',
                    help='Will create a views.py file from your models.py.')

    ap.add_argument('-s', '--serializers',
                    action='store_true',
                    help='Will create a serializers.py file from your models.py.')

    ap.add_argument('-u', '--urls',
                    action='store_true',
                    help='Will create a urls.py file from your models.py.')

    ap.add_argument('-A', '--All',
                    action='store_true',
                    help='Will create four files: urls.py, admin.py, views.py, serializers.py, from your models.py.')

    ap.add_argument('-D', '--Delete',
                    action='store_true',
                    help='\033[91m'+outputdir+' directory will be destroyed!!!''\033[0m')

    args = ap.parse_args()

    models = extractor_obj(args.models_path)
    if models:
        if args.admin:
            make_admin(outputdir)
            if args.verbose:
                print("\033[91madmin.py genereted at!---> \033[93m" + outputdir + "/admin.py")

        if args.views:
            make_views(outputdir)
            if args.verbose:
                print("\033[91mviews.py genereted at!---> \033[93m" + outputdir + "/views.py")

        if args.urls:
            make_urls(outputdir)
            if args.verbose:
                print("\033[91murls.py genereted at!---> \033[93m" + outputdir + "/urls.py")

        if args.serializers:
            make_serializers(outputdir)
            if args.verbose:
                print("\033[91serializers.py genereted at!---> \033[93m" + outputdir + "/serializers.py")

        if args.All:
            make_admin(outputdir)
            make_views(outputdir)
            make_urls(outputdir)
            make_serializers(outputdir)
            if args.verbose:
                print("\033[91madmin.py genereted at!---> \033[93m" + outputdir + "/admin.py")
                print("\033[91mviews.py genereted at!---> \033[93m" + outputdir + "/views.py")
                print("\033[91murls.py genereted at!---> \033[93m" + outputdir + "/urls.py")
                print("\033[91serializers.py genereted at!---> \033[93m" + outputdir + "/serializers.py")

        if args.Delete:
            op = raw_input('\033[91m Warning!!! '+outputdir+'directory will be destroyed!!! do you have sure? yes|not ''\033[0m')
            if op == 'yes':
                shutil.rmtree(outputdir)
                if args.verbose:
                    print('\033[91m'+outputdir+' directory was destroyed!!!''\033[0m')
                    sys.exit(0)
            else:
                print("OK nothing was destroyed.")
                sys.exit(0)

        make_models_improve()
        sys.exit(0)
    else:
        print("can't read models.py, make sure that you was used a valid path/file.")
        sys.exit(1)
コード例 #6
0
def main():
    """
    Method main, set output dir and call a specific function, as given in the options
    :param argv:
    :return: None
    """
    config = RawConfigParser()
    config.readfp(resource_stream('drf_gen', 'config.ini'))

    outputdir = config.get('outputdir', 'dir')
    os.mkdir(outputdir) if not os.path.exists(outputdir) else outputdir

    ap = ArgumentParser()
    ap.add_argument('-vv',
                    '--verbose',
                    default=False,
                    help='Increase verbosity.')

    ap.add_argument('-m',
                    '--model',
                    required=True,
                    action='store',
                    dest='models_path',
                    help='Path to your models.py file.')

    ap.add_argument('-a',
                    '--admin',
                    action='store_true',
                    help='Will create a admin.py file from your models.py.')

    ap.add_argument('-v',
                    '--views',
                    action='store_true',
                    help='Will create a views.py file from your models.py.')

    ap.add_argument(
        '-s',
        '--serializers',
        action='store_true',
        help='Will create a serializers.py file from your models.py.')

    ap.add_argument('-u',
                    '--urls',
                    action='store_true',
                    help='Will create a urls.py file from your models.py.')

    ap.add_argument(
        '-A',
        '--All',
        action='store_true',
        help=
        'Will create four files: urls.py, admin.py, views.py, serializers.py, from your models.py.'
    )

    ap.add_argument('-D',
                    '--Delete',
                    action='store_true',
                    help='\033[91m' + outputdir +
                    ' directory will be destroyed!!!'
                    '\033[0m')

    args = ap.parse_args()

    models = extractor_obj(args.models_path)
    if models:
        if args.admin:
            make_admin(outputdir)
            if args.verbose:
                print("\033[91madmin.py genereted at!---> \033[93m" +
                      outputdir + "/admin.py")

        if args.views:
            make_views(outputdir)
            if args.verbose:
                print("\033[91mviews.py genereted at!---> \033[93m" +
                      outputdir + "/views.py")

        if args.urls:
            make_urls(outputdir)
            if args.verbose:
                print("\033[91murls.py genereted at!---> \033[93m" +
                      outputdir + "/urls.py")

        if args.serializers:
            make_serializers(outputdir)
            if args.verbose:
                print("\033[91serializers.py genereted at!---> \033[93m" +
                      outputdir + "/serializers.py")

        if args.All:
            make_admin(outputdir)
            make_views(outputdir)
            make_urls(outputdir)
            make_serializers(outputdir)
            if args.verbose:
                print("\033[91madmin.py genereted at!---> \033[93m" +
                      outputdir + "/admin.py")
                print("\033[91mviews.py genereted at!---> \033[93m" +
                      outputdir + "/views.py")
                print("\033[91murls.py genereted at!---> \033[93m" +
                      outputdir + "/urls.py")
                print("\033[91serializers.py genereted at!---> \033[93m" +
                      outputdir + "/serializers.py")

        if args.Delete:
            op = raw_input(
                '\033[91m Warning!!! ' + outputdir +
                'directory will be destroyed!!! do you have sure? yes|not '
                '\033[0m')
            if op == 'yes':
                shutil.rmtree(outputdir)
                if args.verbose:
                    print('\033[91m' + outputdir +
                          ' directory was destroyed!!!'
                          '\033[0m')
                    sys.exit(0)
            else:
                print("OK nothing was destroyed.")
                sys.exit(0)

        make_models_improve()
        sys.exit(0)
    else:
        print(
            "can't read models.py, make sure that you was used a valid path/file."
        )
        sys.exit(1)