• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python projects.load_project函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sumatra.projects.load_project函数的典型用法代码示例。如果您正苦于以下问题:Python load_project函数的具体用法?Python load_project怎么用?Python load_project使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了load_project函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: determine_project

def determine_project(sumatra_options):
    if 'project_dir' in sumatra_options and sumatra_options['project_dir']:
        prj = load_project(sumatra_options['project_dir'])
    else:
        try:
            prj = load_project()
        except IOError:
            prj = None
    return prj
开发者ID:Felix11H,项目名称:sumatra,代码行数:9,代码来源:utils.py


示例2: get_context_data

    def get_context_data(self, **kwargs):
        context = super(ProjectListView, self).get_context_data(**kwargs)
        projects = self.get_queryset()

        context['active'] = 'List of projects'
        if not len(projects):
            context['project_name'] = load_project().name
            if not load_project().default_executable:  # empty project: without any records inside
                context['show_modal'] = True
        else:
            context['project_name'] = projects[0]
        return context
开发者ID:evgenjevich,项目名称:sumatra,代码行数:12,代码来源:views.py


示例3: delete

def delete(argv):
    """Delete records or records with a particular tag from a project."""
    usage = "%(prog)s delete [options] LIST"
    description = dedent("""\
      LIST should be a space-separated list of labels for individual records or
      of tags. If it contains tags, you must set the --tag/-t option (see below).
      The special value "last" allows you to delete the most recent simulation/analysis.
      If you want to delete all records, just delete the .smt directory and use
      smt init to create a new, empty project.""")
    parser = ArgumentParser(usage=usage,
                            description=description)
    parser.add_argument('labels', metavar='LIST', nargs="+", help="a space-separated list of labels for individual records or of tags")
    parser.add_argument('-t', '--tag', action='store_true',
                        help="interpret LIST as containing tags. Records with any of these tags will be deleted.")
    parser.add_argument('-d', '--data', action='store_true',
                        help="also delete any data associated with the record(s).")
    args = parser.parse_args(argv)

    project = load_project()

    if args.tag:
        for tag in args.labels:
            n = project.delete_by_tag(tag, delete_data=args.data)
            print("%s records deleted." % n)
    else:
        for label in args.labels:
            if label == 'last':
                label = project.most_recent().label
            try:
                project.delete_record(label, delete_data=args.data)
            except Exception:  # could be KeyError or DoesNotExist: should create standard NoSuchRecord or RecordDoesNotExist exception
                warnings.warn("Could not delete record '%s' because it does not exist" % label)
开发者ID:Felix11H,项目名称:sumatra,代码行数:32,代码来源:commands.py


示例4: comment

def comment(argv):
    """Add a comment to an existing record."""
    usage = "%(prog)s comment [options] [LABEL] COMMENT"
    description = dedent("""\
      This command is used to describe the outcome of the simulation/analysis.
      If LABEL is omitted, the comment will be added to the most recent experiment.
      If the '-f/--file' option is set, COMMENT should be the name of a file
      containing the comment, otherwise it should be a string of text.
      By default, comments will be appended to any existing comments.
      To overwrite existing comments, use the '-r/--replace flag.""")
    parser = ArgumentParser(usage=usage,
                            description=description)
    parser.add_argument('label', nargs='?', metavar='LABEL', help="the record to which the comment will be added")
    parser.add_argument('comment', help="a string of text, or the name of a file containing the comment.")
    parser.add_argument('-r', '--replace', action='store_true',
                        help="if this flag is set, any existing comment will be overwritten, otherwise, the new comment will be appended to the end, starting on a new line")
    parser.add_argument('-f', '--file', action='store_true',
                        help="interpret COMMENT as the path to a file containing the comment")
    args = parser.parse_args(argv)

    if args.file:
        f = open(args.comment, 'r')
        comment = f.read()
        f.close()
    else:
        comment = args.comment

    project = load_project()
    label = args.label or project.most_recent().label
    project.add_comment(label, comment, replace=args.replace)
开发者ID:Felix11H,项目名称:sumatra,代码行数:30,代码来源:commands.py


示例5: repeat

def repeat(argv):
    """Re-run a previous simulation or analysis."""
    usage = "%(prog)s repeat LABEL"
    description = dedent("""\
        Re-run a previous simulation/analysis under (in theory) identical
        conditions, and check that the results are unchanged.""")
    parser = ArgumentParser(usage=usage,
                            description=description)
    parser.add_argument('original_label', metavar='LABEL', help='label of record to be repeated')
    parser.add_argument('-l', '--label', metavar='NEW_LABEL', help="specify a label for the new experiment. If no label is specified, one will be generated automatically.")

    args = parser.parse_args(argv)
    original_label = args.original_label
    project = load_project()
    new_label, original_label = project.repeat(original_label, args.label)
    diff = project.compare(original_label, new_label)
    if diff:
        formatter = get_diff_formatter()(diff)
        msg = ["The new record does not match the original. It differs as follows.",
               formatter.format('short'),
               "run smt diff --long %s %s to see the differences in detail." % (original_label, new_label)]
        msg = "\n".join(msg)
    else:
        msg = "The new record exactly matches the original."
    print(msg)
    project.add_comment(new_label, msg)
开发者ID:Felix11H,项目名称:sumatra,代码行数:26,代码来源:commands.py


示例6: sync

def sync(argv):
    usage = "%(prog)s sync PATH1 [PATH2]"
    description = dedent("""\
        Synchronize two record stores. If both PATH1 and PATH2 are given, the
        record stores at those locations will be synchronized. If only PATH1 is
        given, and the command is run in a directory containing a Sumatra
        project, only that project's records be synchronized with the store at
        PATH1. Note that PATH1 and PATH2 may be either filesystem paths or URLs.
        """)  # need to say what happens if the sync is incomplete due to label collisions
    parser = ArgumentParser(usage=usage,
                            description=description)
    parser.add_argument('path1')
    parser.add_argument('path2', nargs='?')
    args = parser.parse_args(argv)

    store1 = get_record_store(args.path1)
    if args.path2:
        store2 = get_record_store(args.path2)
        collisions = store1.sync_all(store2)
    else:
        project = load_project()
        store2 = project.record_store
        collisions = store1.sync(store2, project.name)

    if collisions:
        print("Synchronization incomplete: there are two records with the same name for the following: %s" % ", ".join(collisions))
        sys.exit(1)
开发者ID:Felix11H,项目名称:sumatra,代码行数:27,代码来源:commands.py


示例7: migrate

def migrate(argv):
    usage = "%(prog)s migrate [options]"
    description = dedent("""\
        If you have moved your data files to a new location, update the record
        store to reflect the new paths.
        """)
    # might also want to update the repository upstream
    # should we keep a history of such changes?
    parser = ArgumentParser(usage=usage,
                            description=description)
    parser.add_argument('-d', '--datapath', metavar='PATH', help="modify the path to the directory in which your results are stored.")
    parser.add_argument('-i', '--input', metavar='PATH', help="modify the path to the directory in which your input data files are stored.")
    parser.add_argument('-A', '--archive', metavar='PATH', help="modify the directory in which your results are archived.")
    parser.add_argument('-M', '--mirror', metavar='URL', help="modify the URL at which your data files are mirrored.")
    args = parser.parse_args(argv)
    project = load_project()
    field_map = {
        "datapath": "datastore.root",
        "input": "input_datastore.root",
        "archive": "datastore.archive",
        "mirror": "datastore.mirror_base_url"
    }

    if not any(vars(args).values()):
        warnings.warn(
            "Command 'smt migrate' had no effect. Please provide at least one "
            "argument. (Run 'smt help migrate' for help.)")
    else:
        for option_name, field in field_map.items():
            value = getattr(args, option_name)
            if value:
                project.record_store.update(project.name, field, value)
开发者ID:Felix11H,项目名称:sumatra,代码行数:32,代码来源:commands.py


示例8: list

def list(argv):  # add 'report' and 'log' as aliases
    """List records belonging to the current project."""
    usage = "%(prog)s list [options] [TAGS]"
    description = dedent("""\
      If TAGS (optional) is specified, then only records tagged with all the tags in TAGS
      will be listed.""")
    parser = ArgumentParser(usage=usage,
                            description=description)
    parser.add_argument('tags', metavar='TAGS', nargs='*')
    parser.add_argument('-l', '--long', action="store_const", const="long",
                        dest="mode", default="short",
                        help="prints full information for each record"),
    parser.add_argument('-T', '--table', action="store_const", const="table",
                        dest="mode", help="prints information in tab-separated columns")
    parser.add_argument('-f', '--format', metavar='FMT', choices=['text', 'html', 'latex', 'shell', 'json'],
                        default='text',
                        help="FMT can be 'text' (default), 'html', 'json', 'latex' or 'shell'.")
    parser.add_argument('-r', '--reverse', action="store_true", dest="reverse", default=False,
                        help="list records in reverse order (default: newest first)")
    parser.add_argument('-m', '--main_file', help="filter list of records by main file")
    parser.add_argument('-P', '--parameter_table', action="store_const", const="parameter_table",
                        dest="mode", help="list records with parameter values")
    args = parser.parse_args(argv)

    project = load_project()
    if os.path.exists('.smt'):
        with open('.smt/labels', 'w') as f:
            f.write('\n'.join(project.get_labels()))

    kwargs = {'tags':args.tags, 'mode':args.mode, 'format':args.format, 'reverse':args.reverse}
    if args.main_file is not None: kwargs['main_file__startswith'] = args.main_file
    print(project.format_records(**kwargs))
开发者ID:GregorWautischer,项目名称:sumatra,代码行数:32,代码来源:commands.py


示例9: list

def list(argv):  # add 'report' and 'log' as aliases
    """List records belonging to the current project."""
    usage = "%(prog)s list [options] [TAGS]"
    description = dedent("""\
      If TAGS (optional) is specified, then only records tagged with all the tags in TAGS
      will be listed.""")
    parser = ArgumentParser(usage=usage,
                            description=description)
    parser.add_argument('tags', metavar='TAGS', nargs='*')
    parser.add_argument('-l', '--long', action="store_const", const="long",
                        dest="mode", default="short",
                        help="prints full information for each record"),
    parser.add_argument('-T', '--table', action="store_const", const="table",
                        dest="mode", help="prints information in tab-separated columns")
    parser.add_argument('-f', '--format', metavar='FMT', choices=['text', 'html', 'latex', 'shell', 'json'],
                        default='text',
                        help="FMT can be 'text' (default), 'html', 'json', 'latex' or 'shell'.")
    parser.add_argument('-r', '--reverse', action="store_true", dest="reverse", default=False,
                        help="list records in reverse order (default: newest first)"),
    args = parser.parse_args(argv)

    project = load_project()
    if os.path.exists('.smt'):
        f = open('.smt/labels', 'w')
        f.writelines(project.format_records(tags=None, mode='short', format='text', reverse=False))
        f.close()
    print(project.format_records(tags=args.tags, mode=args.mode, format=args.format, reverse=args.reverse))
开发者ID:Felix11H,项目名称:sumatra,代码行数:27,代码来源:commands.py


示例10: export

def export(argv):
    usage = "%(prog)s export"
    description = dedent("""\
        Export a Sumatra project and its records to JSON. This is needed before running upgrade.""")
    parser = ArgumentParser(usage=usage,
                            description=description)
    args = parser.parse_args(argv)
    project = load_project()
    project.export()
开发者ID:Felix11H,项目名称:sumatra,代码行数:9,代码来源:commands.py


示例11: settings

def settings(request, project):
    ''' Only one of the following parameter can be True
    web_settings['saveSettings'] == True: save the settings in .smt/project
    web_settings['web'] == True: send project.web_settings to record_list.html
    web_settings['sumatra'] = True: send some spacific settings to record_list.html (they will
    be used in the popup window for the new record as the default values
    '''
    web_settings = {'display_density':request.POST.get('display_density', False),
                    'nb_records_per_page':request.POST.get('nb_records_per_page', False),
                    'table_HideColumns': request.POST.getlist('table_HideColumns[]'),
                    'saveSettings':request.POST.get('saveSettings', False), 
                    'web':request.POST.get('web', False), 
                    'sumatra':request.POST.get('sumatra', False) 
                    }
    nbCols = 14  # total number of columns
    sim_list = models.Record.objects.filter(project__id=project).order_by('-timestamp')
    project_loaded = load_project() 
    if web_settings['saveSettings']:
        if len(web_settings['table_HideColumns']) == 0:  # empty set (all checkboxes are checked)
            project_loaded.web_settings['table_HideColumns'] = []
        try:
            project_loaded.web_settings
        except(AttributeError, KeyError): # project doesn't have web_settings yet
            # upgrading of .smt/project: new supplementary settings entries
            project_loaded.web_settings = init_websettings()   
        for key, item in web_settings.iteritems():
            if item:
                project_loaded.web_settings[key] = item
        project_loaded.save()
        # repetition of code for list_records !!!
        nb_per_page = int(web_settings['nb_records_per_page'])
        paginator = Paginator(sim_list, nb_per_page)
        page_list = paginator.page(1)
        nbCols_actual = nbCols - len(web_settings['table_HideColumns'])
        head_width = '%s%s' %(90.0/nbCols_actual, '%')
        if (nbCols_actual > 10):
            label_width = '150px'
        else:
            label_width = head_width
        dic = {'project_name': project,
               'settings':project_loaded.web_settings,
               'paginator':paginator,
               'object_list':page_list.object_list,
               'page_list':page_list,
               'width':{'head': head_width, 'label':label_width}}
        return render_to_response('content.html', dic)
    elif web_settings['web']: 
        return HttpResponse(simplejson.dumps(project.web_settings))
    elif web_settings['sumatra']:
        settings = {'execut':project.default_executable.path,
                    'mfile':project.default_main_file}
        return HttpResponse(simplejson.dumps(settings))
开发者ID:dcherian,项目名称:sumatra,代码行数:52,代码来源:views_old.py


示例12: info

def info(argv):
    """Print information about the current project."""
    usage = "%(prog)s info"
    description = "Print information about the current project."
    parser = ArgumentParser(usage=usage,
                            description=description)
    args = parser.parse_args(argv)
    try:
        project = load_project()
    except IOError as err:
        print(err)
        sys.exit(1)
    print(project.info())
开发者ID:Felix11H,项目名称:sumatra,代码行数:13,代码来源:commands.py


示例13: export_records

def export_records(output_file):
    store = load_recordstore()
    if minor_version < 3:
        patch_sumatra()
    f = open(output_file, "w")
    if minor_version == 1:
        json.dump([encode_record(record) for record in store.list(groups=None)], f, indent=2)
    else:
        project_name = projects.load_project().name
        if minor_version == 2:
            json.dump([encode_record(record) for record in store.list(project_name)], f, indent=2)
        else:
            f.write(store.export(project_name))
    f.close()
开发者ID:Felix11H,项目名称:sumatra,代码行数:14,代码来源:export.py


示例14: sumatra_start

def sumatra_start(repository, sumatra_db_path, results_path, working_dir, hg_username, sumatra_run_name, parameters):
    '''Clones the Omics Pipe repository from Bitbucket, creates a Sumatra project, and creates a Sumatra record for the current run'''
    print "sumatra_db_path is " + sumatra_db_path
    print type(sumatra_db_path)
    check_create_dir(sumatra_db_path)
    os.chdir(sumatra_db_path)
    repo1 = hgapi.Repo(repository)
    repo_path = sumatra_db_path +"/omics_pipe"
    repo= {"url":repo_path, 
           "type":"sumatra.versioncontrol._mercurial.MercurialRepository",
           "upstream":repository}
    executable= {"path":"",
                 "version": "",
                 "type":"sumatra.programs.PythonExecutable",
                 "options":"",
                 "name": "Python"}
    sumatra_launch_mode = {"working_directory": working_dir, "type": "sumatra.launch.SerialLaunchMode"}
    data_store1 = {"root":results_path, "type": "sumatra.datastore.filesystem.FileSystemDataStore"}
    database_path = sumatra_db_path + "/records/recordstore.db"
    record_store1 = {"db_file": database_path, "type": "sumatra.recordstore.django_store.DjangoRecordStore"}
    input_datastore1 = {"root": results_path, "type": "sumatra.datastore.filesystem.FileSystemDataStore"}
    while True:
        try:
            repo1.hg_clone(url = repository, path=repo_path)
            with open(repo_path + "/.hg/hgrc", "a") as myfile:
                myfile.write("[ui]\nusername= " + hg_username)         
            print "Omics pipe repository cloned to : " + repo_path
            break
        except hgapi.hgapi.HgException:
            print "Omics pipe repository already exists."
            break
    while True:
        try:
            Project(sumatra_run_name, default_repository=repo, default_executable=executable, 
                    default_launch_mode = sumatra_launch_mode, on_changed='store-diff',
                    data_store=data_store1, record_store=record_store1, input_datastore=input_datastore1)            
            print "Sumatra project created: " + sumatra_run_name + " in directory: " + sumatra_db_path
            break
        except Exception:
            print "Sumatra project already exists, loading project: " + sumatra_run_name
            break
    project = load_project(path=sumatra_db_path)
    print project
    sumatra_params = build_parameters(parameters)
    print sumatra_params
    os.chdir(repo_path)
    repo_main = "omics_pipe/main.py"
    record = project.new_record(parameters=sumatra_params, main_file=repo_main)
    print record
    return record,project
开发者ID:adammaikai,项目名称:OmicsPipe2.0,代码行数:50,代码来源:utils.py


示例15: smt_run

    def smt_run(self, line):
        args = parse_argstring(self.smt_run, line)

        global parameters
        if args.flush:
            parameters = build_parameters(args.parameters)
        else:
            parameters = globals().get('parameters',build_parameters(args.parameters))

        global save
        save = args.save

        if args.print:
            print(12*"-" + " Script " + 12*"-")
            with open(args.main_file, 'r') as f:
                script = f.readlines()
            f.closed
            print(''.join(script), end='')
            print(32*"-", end="\n\n")
            print(10*"-" + " Parameters " + 10*"-")
            print(parameters)
            print(32*"-", end="\n\n")

        if args.record is True:
            global record
            project = load_project()
            record = project.new_record(main_file=os.path.relpath(args.main_file),parameters=parameters)
            print("Record label for this run: '%s'" %record.label)

        start_time = time.time()
        execfile(args.main_file, globals(), parameters.as_dict())
        duration = time.time() - start_time

        if args.record is True:
            fname = "%s"%record.label
            if globals().has_key('data'):  np.savetxt("Data/%s.dat"%fname, data)
            if globals().has_key('fig'): fig.savefig("Data/%s.png"%fname)
            record.duration = duration
            record.output_data = record.datastore.find_new_data(record.timestamp)
            project.add_record(record)
            project.save()
            print("Data keys are [%s(%s [%s])"%(record.label, record.version, record.timestamp))

        elif save is True:
            fname = "%s_%s" %(time.strftime("%y%m%d-%H%M%S", time.gmtime(start_time)),
                os.path.splitext(os.path.basename(args.main_file))[0])
            if globals().has_key('data'): np.savetxt("%s.dat"%fname, data)                           # Save data
            if globals().has_key('fig'): fig.savefig("%s.png"%fname)
        print("Duration: %.2fs" %duration)
开发者ID:babsey,项目名称:sumatra_ipython,代码行数:49,代码来源:sumatramagic.py


示例16: inspectFolder

def inspectFolder(foldername, projectpath = '.', timestamp = datetime.datetime(2010, 1, 1, 11, 14, 40, 915039)):
    project = load_project(projectpath)
    logging.debug('Scan folder %s' %foldername)
    initialRoot = project.data_store.root
    project.data_store = datastore.FileSystemDataStore(foldername)
    record = project.new_record(
            main_file=sys.argv[0],
            parameters=foldername,
            executable=sumatra.programs.get_executable(sys.executable),
            reason='Scan folder %s' %foldername
        )
    record.output_data = record.datastore.find_new_data(timestamp)
    project.add_record(record)
    project.save()
    project.data_store = datastore.FileSystemDataStore(initialRoot)
开发者ID:livia-b,项目名称:registerFolders,代码行数:15,代码来源:fakeSumatraRecord.py


示例17: start_web_server

def start_web_server(arguments=None):
    """Launch the Forrest web interface"""
    description = dedent("""\
        Launch the Forrest web interface. There must be a Sumatra
        project in the working directory and the record store for that project
        will be used.""")
    parser = ArgumentParser(description=description)
    parser.add_argument('-a', '--allips', default=False, action="store_true",
                        help="run server on all IPs, not just localhost")
    parser.add_argument('-p', '--port', default="8000",
                        help="run server on this port number")
    parser.add_argument('-n', '--no-browser', default=False, action="store_true",
                        help="do not open browser")
    parser.add_argument('-r', '--read_only', default=False, action="store_true",
                        help="set read-only mode")
    args = parser.parse_args(arguments)

    project = load_project()
    if not isinstance(project.record_store, DjangoRecordStore):
        # should make the web interface independent of the record store, if possible
        print("This project cannot be accessed using the web interface (record store is not of type DjangoRecordStore).")
        sys.exit(1)
    del project

    smt_root_dir = os.path.dirname(sumatra_web)
    db_config.update_settings(
        INSTALLED_APPS=db_config._settings["INSTALLED_APPS"] + ['forrest'] + ['sumatra.web'],
        ROOT_URLCONF='forrest.urls',
        STATIC_URL='/static/',
        TEMPLATE_DIRS=(os.path.join(os.getcwd(), ".smt", "templates"),
                       os.path.join(os.path.dirname(__file__), "templates"),
                       os.path.join(smt_root_dir, "templates"),),
        MIDDLEWARE_CLASSES=tuple(),
        READ_ONLY=args.read_only
    )

    db_config.configure()

    if not args.no_browser:
        thread.start_new_thread(delayed_new_tab, ("http://127.0.0.1:%s" % args.port, 3))

    if args.allips:
        address = '0.0.0.0'
    else:
        address = '127.0.0.1'
    address += ':' + args.port
    management.call_command('runserver', address, use_reloader=False)
开发者ID:philipphanemann,项目名称:forrestgums,代码行数:47,代码来源:main.py


示例18: export_project

def export_project(output_file):
    if minor_version == 3:
        shutil.copy(".smt/project", ".smt/project_export.json")
        return
    elif minor_version == 1:
        prj = projects.load_simulation_project()
    else:
        prj = projects.load_project()
    state = {
        'name': prj.name,
        'on_changed': prj.on_changed,
        'default_main_file': prj.default_main_file,
        'default_executable': None,
        'default_repository': None,
        'default_launch_mode': None,
        'data_store': dict(prj.data_store.get_state(),
                           type=_get_class_path(prj.data_store)),
        'record_store': dict(type=_get_class_path(prj.record_store)),
        'description': getattr(prj, "description", ""), # not in 0.1
        'data_label': getattr(prj, "data_label", None), # not in 0.1
        '_most_recent': getattr(prj, "_most_recent", ""), # not in 0.1
    }
    if prj.default_executable:
        obj = prj.default_executable
        state['default_executable'] = {
            'type': _get_class_path(obj), 'path': obj.path,
            'version': obj.version
        }
    if prj.default_repository:
        obj = prj.default_repository
        state['default_repository'] = {
            'type': _get_class_path(obj), 'url': obj.url,
        }
    if prj.default_launch_mode:
        obj = prj.default_launch_mode
        state['default_launch_mode'] = dict(obj.get_state(),
                                       type=_get_class_path(obj))
    if prj.record_store.__class__.__name__[:6] == 'Django':
        state['record_store']['db_file'] = ".smt/records" #prj.record_store._db_file
    else:
        state['record_store']['shelf_name'] = ".smt/records" #prj.record_store._shelf_name
    f = open(output_file, 'w')
    json.dump(state, f, indent=2)
    f.close()
开发者ID:scottc99,项目名称:sumatra,代码行数:44,代码来源:export.py


示例19: getSMTRecords

def getSMTRecords(records=None, tags=[], parameters={}, atol=1e-10, rtol=1e-10, path='./'):
    if not records:
        project = load_project(path)
        records = project.record_store.list(project.name, tags=tags)
    records_out = []
    for r in records:
        if set(tags).issubset(set(r.tags)):
            allclose = []
            for k, v in parameters.items():
                if np.allclose(v, r.parameters.as_dict()[k], atol=atol, rtol=rtol):
                    allclose.append(True)
                else:
                    allclose.append(False)
            if np.all(allclose):
                records_out.append(r)
            # if set(parameters.items()).issubset(set(r.parameters.as_dict().items())):
            #     records_out.append(r)

    return records_out
开发者ID:wd15,项目名称:extremefill2D,代码行数:19,代码来源:tools.py


示例20: upgrade

def upgrade(argv):
    usage = "%(prog)s upgrade"
    description = dedent("""\
        Upgrade an existing Sumatra project. You must have previously run
        "smt export" or the standalone 'export.py' script.""")
    parser = ArgumentParser(usage=usage,
                            description=description)
    args = parser.parse_args(argv)

    project = load_project()
    if (hasattr(project, 'sumatra_version')
        and project.sumatra_version == sumatra.__version__
        and "dev" not in sumatra.__version__):

        print("No upgrade needed (project was created with an up-to-date version of Sumatra).")
        sys.exit(1)

    if not os.path.exists(".smt/project_export.json"):
        print("Error: project must have been exported (with the original "
              "version of Sumatra) before upgrading.")
        sys.exit(1)

    # backup and remove .smt
    import shutil
    backup_dir = project.backup()
    shutil.rmtree(".smt")
    # upgrade the project data
    os.mkdir(".smt")
    shutil.copy("%s/project_export.json" % backup_dir, ".smt/project")
    project.sumatra_version = sumatra.__version__
    project.save()
    # upgrade the record store
    project.record_store.clear()
    filename = "%s/records_export.json" % backup_dir
    if os.path.exists(filename):
        f = open(filename)
        project.record_store.import_(project.name, f.read())
        f.close()
    else:
        print("Record file not found")
        sys.exit(1)
    print("Project successfully upgraded to Sumatra version {}.".format(project.sumatra_version))
开发者ID:scottc99,项目名称:sumatra,代码行数:42,代码来源:commands.py



注:本文中的sumatra.projects.load_project函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python projects.Project类代码示例发布时间:2022-05-27
下一篇:
Python sum_of_multiples.sum_of_multiples函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap