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

Python executor.Executor类代码示例

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

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



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

示例1: REPL

class REPL(Cmd):
    prompt = 'repl:>> '

    def __init__(self):
        Cmd.__init__(self)
        self.ex = Executor()
        self.trans = translator.Translator()

    def default(self, line):
        try:
            y = yaml.load(line)
            print 'yaml:', y
            js = self.trans.translate(y)
            print 'generated js:', js
            print self.ex.execute(js)
        except Exception as e:
            print e

    def do_EOF(self, line):
        return True
    def do_quit(self, line):
        return True

    def do_reload(self, line):
        reload(translator)
        self.trans = translator.Translator()
        return False
开发者ID:bgnori,项目名称:yamljs,代码行数:27,代码来源:repl.py


示例2: _process_event

    def _process_event(self, event):
        global config
        if event:
            # This still needs some work
            # dependencies = self._check_for_dependencies(config, event)
            dependencies = []
            self.job_count += 1
            job_id = "%s:%d" % (self.name, self.job_count)
            try:
                # Launch test runs
                tests = []
                for test in config['tests']:
                    testexec = Executor(test, event, dependencies)
                    tests.append(testexec)
                    testexec.start()
                    logging.info('Started %s test execution...',
                                 test['test-name'])

                # Wait for all executions to finish
                for test in tests:
                    test.join()
                logging.info('All tests completed')

                # Report the results
                self._publish_results_to_gerrit(
                    config, tests, job_id)

                # Throttle things a little bit
                time.sleep(5)
            except Exception:
                logging.exception('Error in event processing!')
开发者ID:stmcginnis,项目名称:openstack-ci,代码行数:31,代码来源:os_ci.py


示例3: LiquipyDatabase

class LiquipyDatabase(object):
  """
  Main interface for Liquipy
  """

  def __init__(self, host=DEFAULT['host'],
                     database=DEFAULT['database'],
                     username=DEFAULT['username'],
                     password=DEFAULT['password'],
                     tempDir=DEFAULT['tempDir']):
    self.liquibaseExecutor = LiquibaseExecutor(host, database, username, password)
    self.tempDir = tempDir
    self.outputXmlChangeLogFilePath = self.tempDir + "/liquipy_changelog.xml"



  def initialize(self, yamlPath):
    rawYaml = open(yamlPath, 'r').read()
    try:
      changes = yaml.load(rawYaml)
    except yaml.scanner.ScannerError as e:
      msg = "Error parsing input YAML file '%s':\n%s" % (yamlPath, e)
      raise Exception(msg)

    changeSetWriter = ChangeSetWriter(self.outputXmlChangeLogFilePath)
    changeSetWriter.write(changes)



  def update(self):
    self.liquibaseExecutor.run(self.outputXmlChangeLogFilePath, 'update')
开发者ID:oxtopus,项目名称:liquipy,代码行数:31,代码来源:db.py


示例4: show_pattern_and_template

def show_pattern_and_template(dna):
    from executor import Executor

    e = Executor(dna)
    e.explicit_rna_items = True
    
    pattern = e.pattern()
    pattern.append('EoP')
    template = e.template()
    template.append('EoT')
    e.item_starts.append(e.parser.index)
    
    s1 = []
    s2 = []
    for item, begin, end in zip(
                pattern+template, 
                e.item_starts, 
                e.item_starts[1:]):
        e1 = ''.join(e.dna[begin:end])
        e2 = str(item)
        if len(e1) > len(e2):
            e2 += ' '*(len(e1)-len(e2))
        else:
            e1 += ' '*(len(e2)-len(e1))
            
        s1.append(e1)
        s2.append(e2)
        
    print ' '.join(s1)
    print ' '.join(s2)
开发者ID:Vlad-Shcherbina,项目名称:Morph-Endo-Legacy,代码行数:30,代码来源:dna_code.py


示例5: kill_device

 def kill_device(device):
   cmd = "ps xww | grep Simulator.app | grep -s {0} | grep -v grep | awk '{{print $1}}'".format(device.uuid)
   output = Executor.execute(cmd)
   if output == '':
     return
   pid = int(output)
   if pid > 0:
     Executor.execute('kill {0}'.format(pid))
开发者ID:oliverhu,项目名称:simctl,代码行数:8,代码来源:__init__.py


示例6: Hostapd

class Hostapd(object):
    """ Wrapper class for UCI (OpenWRT) commands """
    executor = None
    devicename = None

    def __init__(self, config = "/etc/hostapd/hostapd.conf", wifi_restart_command, executor=None):
        if executor == None:
            self.executor = Executor()
        else:
            self.executor = executor

        self.config = config
        self.restart_command = wifi_restart_command

    def get_wifi_interface(self):
        "Return the wifi interface name (e.g. 'wlan0')"
        ret = self.executor.execute_cmd(['grep', '^interface', self.config, '|', 'cut','-f2','-d"="'])
        
        if ret is None:
            print 'No WiFi device name found.'

        return ret

    def get_bridge_interface(self):
        "Return the bridge interface name (e.g. 'br0')"
        ret = self.executor.execute_cmd(['grep', '^bridge', self.config, '|', 'cut','-f2','-d"="'])
        
        if ret is None:
            print 'No bridge device name found.'

        return ret

    def get_wifi_mode(self):
        "Get operation mode (e.g. n)"
        ret = self.executor.execute_cmd(['grep', '^hw_mode', self.config, '|', 'cut','-f2','-d"="'])
        
        if ret is None:
            print 'No mode found in config.'
        
        return ret

    def set_channel(self, channel):
        "Sets the wifi channel. Requires commit and restart of WiFi for changes to take effect"
        self.executor.execute_cmd(['sudo','cat',self.config,'|','sed','-e',"s/channel=[0-9][0-9]*/channel=%d/g" % channel, '>', '/tmp/tmp_hostapd.conf'])
        self.executor.execute_cmd(['sudo','mv','/tmp/tmp_hostapd.conf',self.config])

    def restart():
        "Restart hostapd"
        self.executor.execute_cmd(wifi_restart_command)

    def get_wifi_ssid(self):
        "Return the wifi ssid (e.g. for 'node1-wifi')"
        ret = self.executor.execute_cmd(['grep', '^ssid', self.config, '|', 'cut','-f2','-d"="'])
        
        if ret is None:
            print 'No SSID found in config.'
        
        return ret
开发者ID:MagnusS,项目名称:pyradac,代码行数:58,代码来源:hostapdtool.py


示例7: LiquipyDatabase

class LiquipyDatabase(object):
    """
  Main interface for Liquipy
  """

    def __init__(
        self,
        host=DEFAULT["host"],
        database=DEFAULT["database"],
        username=DEFAULT["username"],
        password=DEFAULT["password"],
        tempDir=DEFAULT["tempDir"],
    ):
        self.liquibaseExecutor = LiquibaseExecutor(host, database, username, password)
        self.tempDir = tempDir
        self.outputXmlChangeLogFilePath = self.tempDir + "/liquipy_changelog.xml"

    def initialize(self, yamlPath):
        self.changes = self.inputYamlToChangeSets(yamlPath)
        changeSetWriter = ChangeSetWriter(self.outputXmlChangeLogFilePath)
        changeSetWriter.write(self.changes)

    def inputYamlToChangeSets(self, yamlPath):
        rawYaml = open(yamlPath, "r").read()
        try:
            changes = yaml.load(rawYaml)
        except yaml.scanner.ScannerError as e:
            msg = "Error parsing input YAML file '%s':\n%s" % (yamlPath, e)
            raise Exception(msg)
        if "include" in changes.keys():
            relativeTargetDir = changes["include"]["directory"]
            currentDir = join(split(yamlPath)[:-1])[0]
            targetDir = join(currentDir, relativeTargetDir)
            try:
                dirFiles = listdir(targetDir)
            except Exception:
                raise Exception('Included directory "' + targetDir + '" does not exist')
            migrationFiles = [join(targetDir, f) for f in dirFiles if f.endswith(".yml")]
            for includedMigration in migrationFiles:
                includeChanges = self.inputYamlToChangeSets(includedMigration)
                changes.update(includeChanges)
            del changes["include"]
        return changes

    def update(self):
        print "Running all migrations..."
        self.liquibaseExecutor.run(self.outputXmlChangeLogFilePath, "update")

    def rollback(self, tagName):
        print "Rolling back to %s..." % (tagName,)
        self.liquibaseExecutor.run(self.outputXmlChangeLogFilePath, "rollback", tagName)

    def getTags(self):
        return [
            {"tag": self.changes[c]["tag"], "changeSet": c} for c in self.changes.keys() if "tag" in self.changes[c]
        ]
开发者ID:rhyolight,项目名称:liquipy,代码行数:56,代码来源:db.py


示例8: delete

    def delete(self):
        kw = dict((self._basic_fields[i], self.values[i])  for i in self._pk)
        kw['multi'] = None
        kw['alias'] = self.__alias__
        kw['uin'] = self._uin

        w = ' AND '.join('%s = :%s' % (self._basic_fields[i], i) for i in self._pk)
        if w:
            w = 'WHERE ' + w

        Executor.save('DELETE FROM %s %s' % (self.__table__, w), **kw)
开发者ID:uve,项目名称:shiva,代码行数:11,代码来源:engine.py


示例9: save

    def save(self, **kw):
        isnew = kw.pop('isnew', any(self.values[i] is None for i in self._pk))

        if self._dirty or isnew:
            # set default volumes
            for i in self._basic_fields.keys():
                if self.values[i] is None:
                    x = self._fields[i]._default
                    if isinstance(x, (FunctionType, MethodType, BuiltinFunctionType, BuiltinMethodType,)):
                        x = x()

                    elif isinstance(x, Sequence):
                        # print 'W1', x
                        x = x()
                        # print 'W2', x

                    self.__setattr__(i, x)

            kw = {'alias': self.__alias__}
            if isnew:
                fields = []
                for i in self._dirty:
                    k = self._basic_fields[i]
                    kw[k] = self.values[i]
                    fields.append(k)

                sql = 'INSERT INTO %s (%s) VALUES (%s)' % (self.__table__,
                                                         ','.join(fields),
                                                         ','.join(' :%s' % i for i in fields))
            else:
                sets = []
                whr = []
                for i in self._dirty:
                    k = self._basic_fields[i]
                    kw[k] = self.values[i]
                    sets.append('%s = :%s' % (k, k))

                for pk in self._pk:
                    k = self._basic_fields[pk]
                    kw[k] = self.old_values[pk]
                    whr.append('%s = :%s' % (k, k))

                sql = 'UPDATE %s SET %s WHERE %s' % (self.__table__,
                                                     ', '.join(sets),
                                                     ' AND '.join(whr))

            self._dirty = []
            kw['uin'] = self._uin
            Executor.save(sql, **kw)
开发者ID:uve,项目名称:shiva,代码行数:49,代码来源:engine.py


示例10: main

def main():
    current_os = sys.platform
    os_commands = {'linux': 'xdg-open', 'win32': 'start', 'darwin': 'open'}

    script_abs_path = os.path.dirname(os.path.abspath(__file__))
    script_parent_dir = script_abs_path.rsplit(os.sep, 1)[0]
    sys.path.append(script_parent_dir)

    # Check if settings directory exists and create it if it doesn't
    settings_dir = '{}{}settings'.format(script_abs_path, os.sep)
    if not os.path.exists(settings_dir):
        Executor.execute(["mkdir", settings_dir])

    # Check if sync_list file exists and create it if it doesn't
    sync_list_path = '{}{}sync_list.txt'.format(settings_dir, os.sep)
    if not os.path.exists(sync_list_path):
        Executor.execute(["touch", sync_list_path])

    # Get needed command to open default text editor depending on the OS
    command = None
    if 'linux' in current_os:
        command = os_commands['linux']
    elif 'win32' in current_os:
        command = os_commands['win']
    elif 'darwin' in current_os:
        command = os_commands['darwin']

    error_message = \
        """ERROR:    An error occured while trying to open
            "{}" for writing.

    REASON:   One possible reason is that your
            operating system is not supported.

            Your current operating system:  {}
            Supported operating systems:    {}

            If your operating system is not in the list or
            it is but you still see this error
            please give a feedback to support the development
            of this app and you to be able to use it.

    SOLUTION: For now you can edit the sync list manually
            as you open it with some text editor."""\
            .format(sync_list_path, current_os, ', '.join(os_commands.keys()))

    if command is None or not Executor.execute([command, sync_list_path]):
        print(error_message)
开发者ID:dragonator,项目名称:ytsync,代码行数:48,代码来源:edit_sync_list.py


示例11: __call__

    def __call__(self, parent):
        if isinstance(self._cls, basestring):
            self._cls = Executor.classes[self._cls]

        # codtition
        if self._condition:
            c1, c2 = [i.strip() for i in  self._condition.split('=')]

            if c2.startswith(parent.__class__.__name__ + '.'):
                c1, c2 = c2, c1

            c1a, c1b = c1.split('.')
            c2a, c2b = c2.split('.')

            if parent.__class__.__name__ <> c1a or self._cls.__name__ <> c2a:
                raise ReferenceException('Invalid condition "%s" by classes "%s" and "%s"' % (self._condition, c1, c2))

            return self._cls._read(self._multi, **{c2b:parent.values[c1b]})

        # if function of SQL generating 
        elif self._generator:
            if isinstance(self._generator, basestring):
                self._generator = parent.__class__.__dict__[self._generator]

            sql, kw = self._generator(parent)

            # None-классы т.е. SQL-функции
            if self._cls is None:
                return Executor.exec_sql(sql, multi=False, **kw).data[0]
            # Внешние классы
            else:
                return self._cls._read(self._multi, sql=sql, **kw)
开发者ID:uve,项目名称:shiva,代码行数:32,代码来源:columns.py


示例12: __init__

    def __init__(self, config = "/etc/hostapd/hostapd.conf", wifi_restart_command, executor=None):
        if executor == None:
            self.executor = Executor()
        else:
            self.executor = executor

        self.config = config
        self.restart_command = wifi_restart_command
开发者ID:MagnusS,项目名称:pyradac,代码行数:8,代码来源:hostapdtool.py


示例13: __init__

 def __init__(self, host=DEFAULT['host'],
                    database=DEFAULT['database'],
                    username=DEFAULT['username'],
                    password=DEFAULT['password'],
                    tempDir=DEFAULT['tempDir']):
   self.liquibaseExecutor = LiquibaseExecutor(host, database, username, password)
   self.tempDir = tempDir
   self.outputXmlChangeLogFilePath = self.tempDir + "/liquipy_changelog.xml"
开发者ID:oxtopus,项目名称:liquipy,代码行数:8,代码来源:db.py


示例14: __init__

 def __init__(self, limb, hover_distance = 0.15, verbose=True):
     self._limb_name = limb # string
     self._hover_distance = hover_distance # in meters
     self._verbose = verbose # bool
     self._executor = Executor(limb, verbose)
     trajsvc = "baxter_adapt/imitation_server"
     rospy.wait_for_service(trajsvc, 5.0)
     self._trajsvc = rospy.ServiceProxy(trajsvc, Imitation)
开发者ID:neroam,项目名称:baxter_adapt,代码行数:8,代码来源:baxter_adapt_demo_sim.py


示例15: list_runtimes

 def list_runtimes(self):
   output = Executor.execute(CMD.format('runtimes'))
   runtime_list = json.loads(output)['runtimes']
   return [RunTime(runtime['availability'],
                   runtime['buildversion'],
                   runtime['identifier'],
                   runtime['name'],
                   runtime['version']) for runtime in runtime_list]
开发者ID:oliverhu,项目名称:simctl,代码行数:8,代码来源:list_device.py


示例16: test_files_created

    def test_files_created(self):
        """Test that we can run experiments and get output files"""
        conf_name = 'myconf'
        wl_name = 'mywl'

        results_dir = os.path.join(self.te.LISA_HOME, 'results', self.res_dir,
                                   'rtapp:{}:{}'.format(conf_name, wl_name))
        if os.path.isdir(results_dir):
            shutil.rmtree(results_dir)

        experiments_conf = {
            'confs': [{
                'tag': conf_name
            }],
            "wloads" : {
                wl_name : {
                    "type" : "rt-app",
                    "conf" : {
                        "class" : "profile",
                        "params" : {
                            "mytask" : {
                                "kind" : "Periodic",
                                "params" : {
                                    "duty_cycle_pct": 10,
                                    "duration_s": 0.2,
                                },
                            },
                        },
                    },
                },
            },
        }

        executor = Executor(self.te, experiments_conf)
        executor.run()

        self.assertTrue(
            os.path.isdir(results_dir),
            'Expected to find a directory at {}'.format(results_dir))

        result_1_dir = os.path.join(results_dir, '1')
        self.assertTrue(
            os.path.isdir(result_1_dir),
            'Expected to find a directory at {}'.format(result_1_dir))
开发者ID:credp,项目名称:lisa,代码行数:44,代码来源:test_executor.py


示例17: main

def main():
    """
    Calls the executor to execute a script along with required job
    config
    """
    if len(sys.argv) < 2:
        print 'Missing script name'
        sys.exit(1)
    elif len(sys.argv) < 3:
        print 'Missing job ENVs path'
        sys.exit(1)
    else:
        script_path = sys.argv[1]
        job_envs_path = sys.argv[2]

    config = Config(script_path, job_envs_path)
    ex = Executor(config)
    ex.execute()
    sys.exit(ex.exit_code)
开发者ID:mohit5it9,项目名称:reqExec,代码行数:19,代码来源:main.py


示例18: put

    def put(self, project_name, task):
        """ Put the task to the executor thread associated to the project name.
        If the thread does not exist, it will be created.
        """

        # Get the executor thread associated to the project name.
        executor = self.executors.get(project_name)
        if not executor:
            # The thread does not exist yet. Create a new one.
            executor = Executor()

            # Associate this new thread to the project_name.
            self.executors[project_name] = executor

            # Start the thread.
            executor.start()

        # Put the task to the good executor thread.
        executor.tasks.put(task)
开发者ID:SeyZ,项目名称:baboon,代码行数:19,代码来源:dispatcher.py


示例19: __init__

 def __init__(
     self,
     host=DEFAULT["host"],
     database=DEFAULT["database"],
     username=DEFAULT["username"],
     password=DEFAULT["password"],
     tempDir=DEFAULT["tempDir"],
 ):
     self.liquibaseExecutor = LiquibaseExecutor(host, database, username, password)
     self.tempDir = tempDir
     self.outputXmlChangeLogFilePath = self.tempDir + "/liquipy_changelog.xml"
开发者ID:rhyolight,项目名称:liquipy,代码行数:11,代码来源:db.py


示例20: list_devices

 def list_devices(self):
   output = Executor.execute(CMD.format('devices'))
   os_device_list = json.loads(output)['devices']
   device_array = []
   for os in os_device_list:
     device_array += [Device(device_dict['availability'],
                      device_dict['name'],
                      os,
                      device_dict['state'],
                      device_dict['udid']
                      ) for device_dict in os_device_list[os]]
   return device_array
开发者ID:oliverhu,项目名称:simctl,代码行数:12,代码来源:list_device.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python exercise1.grade_to_gpa函数代码示例发布时间:2022-05-24
下一篇:
Python executor.run函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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