当前位置: 首页>>代码示例>>Python>>正文


Python executor.run函数代码示例

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


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

示例1: __init__

    def __init__(self, master=None):
        
        if 'MESOS_SLAVE_PID' in os.environ and 'DRUN_SIZE' not in os.environ:
            from executor import run
            run()
            sys.exit(0)
        
        options = parse_options()
        self.master = master or options.master

        if self.master.startswith('local'):
            self.scheduler = LocalScheduler()
            self.isLocal = True
        elif self.master.startswith('process'):
            self.scheduler = MultiProcessScheduler(options.parallel)
            self.isLocal = True
        elif (self.master.startswith('mesos')
              or self.master.startswith('zoo')):
            if '://' not in self.master:
                self.master = os.environ.get('MESOS_MASTER')
                if not self.master:
                    raise Exception("invalid uri of mesos master: %s" % self.master)
            self.scheduler = MesosScheduler(self.master, options) 
            self.isLocal = False
        else:
            raise Exception("invalid master option: %s" % self.master)

        if options.parallel:
            self.defaultParallelism = options.parallel
        else:
            self.defaultParallelism = self.scheduler.defaultParallelism()
        self.defaultMinSplits = max(self.defaultParallelism, 2)
       
        self.started = False
开发者ID:Credochen,项目名称:dpark,代码行数:34,代码来源:context.py

示例2: __init__

    def __init__(self, master=None):
        
        if 'MESOS_SLAVE_PID' in os.environ and 'DRUN_SIZE' not in os.environ:
            from executor import run
            run()
            sys.exit(0)
        
        options = parse_options()
        self.options = options
        master = master or options.master

        if master == 'local':
            self.scheduler = LocalScheduler()
            self.isLocal = True
        elif master == 'process':
            self.scheduler = MultiProcessScheduler(options.parallel)
            self.isLocal = True
        else:
            if master == 'mesos':
                master = os.environ.get('MESOS_MASTER')
                if not master:
                    raise Exception("invalid uri of mesos master: %s" % master)
            if master.startswith('mesos://'):
                if '@' in master:
                    master = master[master.rfind('@')+1:]
                else:
                    master = master[master.rfind('//')+2:]
            elif master.startswith('zoo://'):
                master = 'zk' + master[3:]

            if ':' not in master:
                master += ':5050'
            self.scheduler = MesosScheduler(master, options) 
            self.isLocal = False
            
        self.master = master

        if options.parallel:
            self.defaultParallelism = options.parallel
        else:
            self.defaultParallelism = self.scheduler.defaultParallelism()
        self.defaultMinSplits = max(self.defaultParallelism, 2)
      
        try:
            from rfoo.utils import rconsole
            rconsole.spawn_server(locals(), 0)
        except ImportError:
            pass

        self.started = False
开发者ID:cute,项目名称:dpark,代码行数:50,代码来源:context.py

示例3: blockify_cpu

def blockify_cpu():
  """ Print the CPU load average and temperature """
  
  block = Powerblock("cpu")

  cpuload = executor.run("uptime | awk -F'[a-z]:' '{ print $2}'")[0]
  oneminload = float(cpuload.split(",")[0] + "." + cpuload.split(",")[1])
  cputemp = executor.run("cat /sys/class/thermal/thermal_zone7/temp")[0]
  temp = int(cputemp) / 1000
  
  if oneminload > 3 or temp > 80:
    block.set_urgent()

  block.set_text(str(oneminload) + "/" + str(temp))
  return block
开发者ID:eXenon,项目名称:dotfiles,代码行数:15,代码来源:i3bar.py

示例4: blockify_battery

def blockify_battery():
  """ Print the current battery level. """

  block = StatusUnit('battery')
  block.set_icon('')

  acpi = executor.run('acpi -b')[0]
  battery = re.search('\d*%', acpi).group(0)
  battery_int = int(battery[:-1])
  is_charging = bool(re.search('Charging|Unknown', acpi))

  if is_charging:
    block.set_icon('')
  elif battery_int > 90:
    block.set_icon('')
  elif battery_int > 60:
    block.set_icon('')
  elif battery_int > 30:
    block.set_icon('')
  elif battery_int > 10:
    block.set_icon('')
  else:
    block.set_icon('')

  if is_charging:
    block.set_text('')
  else:
    block.set_text(battery)
    block.set_background(colors['red'])
    block.set_color(colors['white'], colors['white'])

  return block
开发者ID:qtm,项目名称:dotfiles,代码行数:32,代码来源:conkyrc-left.py

示例5: download

def download(target_dir, urls, filenames=None,\
    parallelism=10, creds=None, tries=3, extract=False):
    """ downloads large files either locally or on a remote machine
    @target_dir: where to download to
    @urls: a list of urls or a single url
    @filenames: list of filenames. If used, the the urls will be downloaded to
        those file names
    @parallelism(default=10): number of parallel processes to use
    @creds: dictionary with credentials
        if None, it will download locally
        if not None, then wget command will be run on a remote host
    @extract: boolean - whether to extract tar or zip files after download
    """
    if isinstance(urls, str):
        urls = [urls]

    if not isinstance(urls, list):
        raise Exception('Expected a list of urls. Received %s' % urls)

    if not os.path.exists(target_dir):
        os.makedirs(target_dir)

    cmds = []
    if filenames is None:
        filenames = [__url_to_filename(_url) for _url in urls]

    if isinstance(filenames, str):
        filenames = [filenames]

    if len(filenames) != len(urls):
        raise Exception('You have specified filenames but the number of filenames '\
            'does not match the number of urls')

    for ind, _url in enumerate(urls):
        filename = filenames[ind]
        file_path = os.path.join(target_dir, filename)
        cmd = 'wget -O "{}" -t {} -T {} -q "{}"'.format(file_path, tries, TIMEOUT, _url)
        if extract:
            ext = compression.get_unzip_cmd(file_path)
            if ext is not None:
                cmd = "{};cd {};{} {}".format(cmd, target_dir, ext, filename)
        cmds.append(cmd)
    executor.run(cmds, parallelism=parallelism, curr_dir=target_dir, creds=creds)
开发者ID:kouroshparsa,项目名称:parallel_sync,代码行数:43,代码来源:wget.py

示例6: blockify_topprocess

def blockify_topprocess():
  """ Print the top CPU consuming process """
  
  block = StatusUnit("topcpu")
  block.set_icon("T")

  topprocess = executor.run("ps aux | sort -rk 3,3 | head -n 2 | tail -n 1 | rev | sed -e 's/^[[:space:]]*//' | cut -d' ' -f 1 | rev")[0]
  block.set_text(str(topprocess))
  block.status_block.set_min_width(40, "right")
  return block.to_json()
开发者ID:eXenon,项目名称:dotfiles,代码行数:10,代码来源:conkyrc.py

示例7: blockify_cpu

def blockify_cpu():
  """ Print the CPU load average and temperature """
  
  block = StatusUnit("cpu")
  block.set_icon("C")

  cpuload = executor.run("uptime | awk -F'[a-z]:' '{ print $2}'")[0]
  oneminload = float(cpuload.split(",")[0] + "." + cpuload.split(",")[1])
  cputemp = executor.run("cat /sys/class/thermal/thermal_zone7/temp")[0]
  temp = int(cputemp) / 1000
  
  if oneminload > 3 or temp > 80:
    block.set_urgent()
  elif oneminload > 1 or temp > 60:
    block.set_border(colors["urgent"], 0, TOP_BORDER_WIDTH, 0, 0)

  block.set_text(str(oneminload) + "/" + str(temp))
  block.status_block.set_min_width(40, "right")
  return block.to_json()
开发者ID:eXenon,项目名称:dotfiles,代码行数:19,代码来源:conkyrc.py

示例8: blockify_active_window

def blockify_active_window():
  """ Print the currently active window (or 'none'). """

  active_window, return_code = executor.run('xdotool getactivewindow getwindowname')
  if return_code != 0:
    return None
  if len(active_window) > 100:
    active_window = active_window[:80] + '...' + active_window[-20:]

  block = Powerblock('active-window')
  block.set_text(active_window)

  return block
开发者ID:eXenon,项目名称:dotfiles,代码行数:13,代码来源:i3bar.py

示例9: blockify_internet

def blockify_internet():
  """ Prints primary IP and ping time to 8.8.8.8.
      Alerts when ping is high or IP not found.
  """
  block = Powerblock("internet")

  pingtime = executor.run("fping -C 1 -t 200 8.8.8.8")[0]
  ip = executor.run("ip a | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'")[0]
  if len(ip) < 4:
    block.set_urgent()
    block.set_text("NO IP")
  else:
    if len(pingtime) < 4:
      block.set_text(ip + " >200 ms")
      block.set_hl()
    else:
      pingtime = float(pingtime.split(" ")[5])
      if pingtime > 500:
        block.set_hl()
      elif pingtime > 1000:
        block.set_urgent()
      block.set_text(ip + " " + str(pingtime) + " ms")
  
  return block
开发者ID:eXenon,项目名称:dotfiles,代码行数:24,代码来源:i3bar.py

示例10: blockify_battery

def blockify_battery():
  """ Print the current battery level. """

  block = Powerblock('battery')

  acpi = executor.run('acpi -b')[0]
  battery = re.search('\d*%', acpi).group(0)
  battery_int = int(battery[:-1])
  is_charging = bool(re.search('Charging|Unknown', acpi))

  block.set_text(battery)
  if battery_int < 40 and not is_charging:
    block.set_hl()
  elif battery_int < 20 and not is_charging:
    block.set_urgent()


  return block
开发者ID:eXenon,项目名称:dotfiles,代码行数:18,代码来源:i3bar.py

示例11: blockify_battery

def blockify_battery():
  """ Print the current battery level. """

  block = StatusUnit('battery')
  block.set_icon('')

  acpi = executor.run('acpi -b')[0]
  battery = re.search('\d*%', acpi).group(0)
  battery_int = int(battery[:-1])
  is_charging = bool(re.search('Charging|Unknown', acpi))

  if is_charging:
    block.set_icon('')
  elif battery_int > 90:
    block.set_icon('')
  elif battery_int > 50:
    block.set_icon('')
  elif battery_int > 20:
    block.set_icon('')
  else:
    block.set_icon('')

  block.set_text(battery)

  if battery_int > 10 or is_charging:
    color = get_color_gradient(battery_int, [ 
      { 'threshold': 0,   'color': colors['urgent'] },
      { 'threshold': 20,  'color': colors['urgent'] },
      { 'threshold': 80,  'color': colors['lime'] },
      { 'threshold': 100, 'color': colors['lime'] } ])
    #block.set_border(colors["blue"], 0, 1, 0, 1)
  else:
    #block.set_urgent()
    pass

  block.status_block.set_min_width(40, 'right')
  return block.to_json()
开发者ID:eXenon,项目名称:dotfiles,代码行数:37,代码来源:conkyrc.py

示例12: get_volume

def get_volume():
  return executor.run('amixer -D pulse get Master | grep -o "\[.*%\]" | grep -o "[0-9]*" | head -n1')[0]
开发者ID:Airblader,项目名称:dotfiles,代码行数:2,代码来源:volume_control.py

示例13: get_active_sink

def get_active_sink():
  return executor.run('pacmd list-sinks | grep "* index" | awk \'{print $3}\'')[0]
开发者ID:Airblader,项目名称:dotfiles,代码行数:2,代码来源:volume_control.py

示例14: is_muted

def is_muted():
  return not executor.run('amixer -D pulse get Master | grep -o "\[on\]" | head -n1')[0]
开发者ID:Airblader,项目名称:dotfiles,代码行数:2,代码来源:volume_control.py

示例15: toggle_volume

def toggle_volume():
  executor.run('amixer -D pulse set Master Playback Switch toggle')
开发者ID:Airblader,项目名称:dotfiles,代码行数:2,代码来源:volume_control.py


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