本文整理汇总了Python中executor.Executor.execute方法的典型用法代码示例。如果您正苦于以下问题:Python Executor.execute方法的具体用法?Python Executor.execute怎么用?Python Executor.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类executor.Executor
的用法示例。
在下文中一共展示了Executor.execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: REPL
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import execute [as 别名]
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
示例2: kill_device
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import execute [as 别名]
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))
示例3: main
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import execute [as 别名]
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)
示例4: list_runtimes
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import execute [as 别名]
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]
示例5: process_conversion
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import execute [as 别名]
def process_conversion(self):
for song in self.files_to_convert:
current_format = ".{}".format(song.rsplit('.', 1)[-1])
old_file = '{}{}{}'.format(self.target_dir, os.sep, song)
new_file = '{}{}{}'.format(self.target_dir, os.sep,
song.replace(current_format, '.mp3'))
message = "Converting {} to 'mp3' format...".format(old_file)
Executor.print_utf(message)
avconv_call = ["avconv", "-i",
old_file.replace(' ', '\ ').replace('|', '\|'),
new_file.replace(' ', '\ ').replace('|', '\|')]
if Executor.execute(avconv_call):
message = 'Deleting {}'.format(old_file)
Executor.print_utf(message)
Executor.execute(["rm", old_file])
示例6: main
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import execute [as 别名]
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)
示例7: list_devices
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import execute [as 别名]
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
示例8: perform
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import execute [as 别名]
def perform(submission):
result = {"id": submission["id"]}
working_folder = os.path.join(config.PLAYGROUND_PATH, str(os.getpid())) + '/'
if submission.has_key('destination_queue'):
result['start_time'] = time.time()
try:
executor = Executor(submission["lang"].upper(), submission["task"],
submission["source"], working_folder)
(result["result"], result["fail_cause"]) = executor.execute()
except ImportError as error:
result["result"] = "failed"
result["fail_cause"] = "We are sorry, but this language is not available."
if submission.has_key('destination_queue'):
queue = submission['destination_queue']
result['finish_time'] = time.time()
else:
queue = RESQUE_CONFIG['queue_resque']
worker = RESQUE_CONFIG['worker_resque']
ResQ().push(queue, {'class': worker, 'args': [result]})
示例9: erase_device
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import execute [as 别名]
def erase_device(device):
cmd = 'xcrun simctl erase {0}'.format(device.uuid)
Executor.execute(cmd)
示例10: list_device_types
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import execute [as 别名]
def list_device_types(self):
output = Executor.execute(CMD.format('devicetypes'))
device_type_list = json.loads(output)['devicetypes']
return [DeviceType(device_type['identifier'], device_type['name']) for device_type in device_type_list]
示例11: Executor
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import execute [as 别名]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from executor import Executor
if __name__ == '__main__':
e = Executor()
e.execute('sapns.exc.update.update', 'Update')
示例12: create_device
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import execute [as 别名]
def create_device(name, device_type, runtime):
cmd = 'xcrun simctl create "{0}" "{1}" "{2}"'.format(name, device_type.identifier, runtime.identifier)
uuid = Executor.execute(cmd)
device = Device(uuid=uuid, name=name)
return device
示例13: Bot
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import execute [as 别名]
class Bot(object):
"""The core of the IRC bot. It maintains the IRC connection, and delegates other tasks."""
def __init__(self):
self.base_path = os.path.dirname(os.path.abspath(__file__))
self.config_path = os.path.abspath(os.path.join(self.base_path, "..", "config.json"))
self.log_path = os.path.abspath(os.path.join(self.base_path, 'logs'))
with open(self.config_path, 'r') as f:
self.configuration = json.load(f)
self.last_message_sent = time()
self.last_ping_sent = time()
self.last_received = None
self.shutdown = False
self.socket = None
self.executor = Executor(self)
self.header = {"User-Agent": "GorillaBot (https://github.com/molly/GorillaBot)"}
self.initialize()
def action(self, target, message):
"""Perform an action to target on the server."""
self.private_message(target, "\x01ACTION " + message + "\x01")
def caffeinate(self):
"""Make sure the connection stays open."""
now = time()
if now - self.last_received > 150:
if self.last_ping_sent < self.last_received:
self.ping()
elif now - self.last_received > 60:
print('No ping response in 60 seconds. Shutting down.')
self.shutdown = True
def connect(self):
"""Connect to the IRC server."""
self.socket = socket.socket()
self.socket.settimeout(5)
try:
print('Initiating connection.')
self.socket.connect(("chat.freenode.net", 6667))
except OSError:
print("Unable to connect to IRC server. Check your Internet connection.")
self.shutdown = True
else:
self.send("NICK {0}".format(self.configuration["nick"]))
self.send("USER {0} 0 * :{1}".format(self.configuration["ident"],
self.configuration["realname"]))
self.private_message("NickServ", "ACC")
self.loop()
def dispatch(self, line):
"""Inspect this line and determine if further processing is necessary."""
length = len(line)
message = None
print(line)
if length >= 2:
if line[0] == "PING":
self.pong(line[1])
elif line[1].isdigit():
message = Numeric(self, *line)
elif line[1] == "NOTICE":
message = Notice(self, *line)
elif line[1] == "PRIVMSG":
message = Privmsg(self, *line)
if message:
self.executor.execute(message)
def initialize(self):
"""Initialize the bot. Parse command-line options, configure, and set up logging."""
print('\n ."`".'
'\n / _=_ \\ \x1b[32m __ __ __ . . . __ __ __ '
'___\x1b[0m\n(,(oYo),) \x1b[32m / _` / \ |__) | | | |__| '
'|__) / \ | \x1b[0m\n| " | \x1b[32m \__| \__/ | \ | |__ '
'|__ | | |__) \__/ | \x1b[0m \n \(\_/)/\n')
self.connect()
def is_admin(self, user):
"""Check if user is a bot admin."""
mask = self.parse_hostmask(user)
return mask["host"] in self.configuration["botops"]
def join(self, chans=None):
"""Join the given channel, list of channels, or if no channel is specified, join any
channels that exist in the config but are not already joined."""
if chans is None:
chans = self.configuration["channels"]
if chans:
for chan in chans.keys():
if not chans[chan]["joined"]:
self.send('JOIN ' + chan)
self.configuration["channels"][chan]["joined"] = True
else:
for chan in chans:
self.send('JOIN ' + chan)
self.configuration["chans"].update({chan: {"joined": True}})
self.update_configuration()
def loop(self):
"""Main connection loop."""
#.........这里部分代码省略.........
示例14: launch_device
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import execute [as 别名]
def launch_device(device):
xcode_address = Executor.execute('xcode-select -p')
cmd = "open -n {0}/Applications/Simulator.app --args -ConnectHardwareKeyboard 0 -CurrentDeviceUDID {1}".format(xcode_address, device.uuid)
Executor.execute(cmd)
示例15: execCommand
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import execute [as 别名]
def execCommand(self, proto, cmd):
"""Execute a git-shell command."""
# This starts an auth request and returns.
executor = Executor(cmd,self.user,proto)
executor.execute()