本文整理汇总了Python中process.Process类的典型用法代码示例。如果您正苦于以下问题:Python Process类的具体用法?Python Process怎么用?Python Process使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Process类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, *args, **kwargs):
Process.__init__(self)
if (len(args) > 1 and
not any(isinstance(arg, (TableExpression, list, tuple))
for arg in args)):
args = (args,)
self.args = args
suffix = kwargs.pop('suffix', '')
fname = kwargs.pop('fname', None)
mode = kwargs.pop('mode', 'w')
if kwargs:
kwarg, _ = kwargs.popitem()
raise TypeError("'%s' is an invalid keyword argument for csv()"
% kwarg)
if fname is not None and suffix:
raise ValueError("csv() can't have both 'suffix' and 'fname' "
"arguments")
if fname is None:
suffix = "_" + suffix if suffix else ""
fname = "{entity}_{period}" + suffix + ".csv"
self.fname = fname
if mode not in ('w', 'a'):
raise ValueError("csv() mode argument must be either "
"'w' (overwrite) or 'a' (append)")
self.mode = mode
示例2: mount
def mount(parent, device):
mountpoint, options = query_mount(parent, device)
if not mountpoint:
return None
command = ('mount', '-t', 'ocfs2', device, mountpoint)
if options:
command = list(command)
command[1:1] = ('-o', options)
p = Process(command, 'Mount', 'Mounting...', parent, spin_now=True)
success, output, killed = p.reap()
if not success:
if killed:
error_box(parent, 'mount died unexpectedly! Your system is '
'probably in an inconsistent state. You '
'should reboot at the earliest opportunity')
else:
error_box(parent, '%s: Could not mount %s' % (output, device))
return None
else:
return mountpoint
示例3: __init__
def __init__(self,context,pid):
Process.__init__(self,context,pid)
if 'config' in context:
self._config = context['config']
#display( OUTPUT_DEBUG, str(self.__config__) )
else:
raise Exception('RandomTestProcess','no config found in context.')
self._start = time()
self._tasktime = 1
self._nextid = 0
if 'process' in self._config:
if 'tasktime' in self._config['process']:
self._tasktime = float(self._config['process']['tasktime'])
if 'period' in self._config['process']:
self._period = float(self._config['process']['period'])
if 'ctrltasktime' in self._config['process']:
self._ctrltasktime = float(self._config['process']['ctrltasktime'])
if 'maxtasks' in self._config['process']:
self._maxtasks = int(self._config['process']['maxtasks'])
self.__queueRandomTestTask__(10)
self.determineState()
示例4: __init__
def __init__(self, env, me):
Process.__init__(self)
self.ballot_number = None
self.accepted = PValueSet()
self.me = me
self.env = env
self.env.addProc(self)
示例5: start
def start(self):
Process.start(self)
msg = RegisterExecutorMessage()
msg.framework_id.MergeFrom(self.framework_id)
msg.executor_id.MergeFrom(self.executor_id)
print 'RegisterExecutorMessage', msg
return self.send(self.slave, msg)
示例6: Skandal
class Skandal():
'''Change config, capture, process.'''
def __init__(self):
self.cf = load_config("./scan.ini")
self.cap = Capture(self.cf)
self.proc = Process(self.cf)
def change_config(self):
pass
def set_cam_position(self):
self.cap.set_cam_position()
def shot(self):
self.cap.shot()
def process_images(self):
self.proc.get_laser_line()
def process_PLY(self):
self.proc.get_PLY()
def scan(self):
self.shot()
self.process_images()
self.process_PLY()
示例7: __init__
def __init__(self, args, desc, parent=None):
if isinstance(args, basestring):
command = '%s %s' % (self.program, args)
else:
command = (self.program,) + tuple(args)
Process.__init__(self, command, self.title, desc, parent)
示例8: __init__
def __init__(self,context,id):
Process.__init__(self,context,id)
if 'config' in context:
self.__config__ = context['config']
else:
raise Exception('WestGridStatusProcess','no config found in context.')
if 'process' in self.__config__:
if 'host' in self.__config__['process']:
self.__host__ = self.__config__['process']['host']
else:
raise Exception('WestGridProcess','required field [process]:host not found in workfile')
if 'user' in self.__config__['process']:
self.__user__ = self.__config__['process']['user']
else:
self.__user__ = environ['USER']
if 'key' in self.__config__['process']:
self.__key__ = self.__config__['process']['key']
else:
if 0 == system( 'touch ~/.ssh/id_rsa &> /dev/null' ):
self.__key__ = '~/.ssh/id_rsa'
else:
raise Exception('WestGridProcess','required field [process]:key="~/.ssh/id_rsa" not found in workfile')
else:
raise Exception('WestGridProcess','no process section found in workfile')
self.__last_time__ = 0
self.__jobs__ = {}
task = WG_DeployTask( self.id(), None, self.__config__ )
task.execute()
示例9: main
def main():
p=Process()
print(p.proces('5+6-(2*6-3)/3'))
print(p.proces('12+2*6-(15/3*2)-7'))
print(p.proces('5/1-5+2*(7+2/2*7)-4/2'))
print(p.proces('(8/2*6)-4+(14*2)-50'))
return
示例10: run_simulation
def run_simulation(req):
''' launch the ros node that calls gazebo using the appropriate world and urdf model
on the commandline, this command would look like this:
roslaunch atlas_utils atlas_cga.launch gzworld:=/home/ben/atlas_cga.world gzrobot:=/home/ben/Desktop/gz_walk_dynopt/gz_walking/models/atlas_cga/model2.urdf
we grab the output of this node from stdout and analyze it
'''
# req may contain a preset non-clashing gazebo simulation ID for parallel execution
trqTotal = 0
global world_loc, model_loc
cmd = "roslaunch atlas_utils atlas_cga.launch gzworld:=%s gzrobot:=%s" % (world_loc, model_loc)
proc = Process(cmd.split(), stdout=True)
while True:
try:
line = proc.readline('stdout', block=True)
except KeyboardInterrupt, rospy.ROSInterruptException:
proc.kill()
break
if line and line.startswith('~~~'):
trq = float(line.split()[4])
trqTotal += trq*trq
if line and line.startswith('=== END '):
print line
print 'Total Torque Squared', trqTotal
break
示例11: __init__
def __init__(self,context,id):
Process.__init__(self,context,id)
if 'config' in context:
self.__config__ = context['config']
#display( OUTPUT_DEBUG, str(self.__config__) )
else:
raise Exception('ExperimentProcess','no config found in context.')
repeat = 0
runs = 0
if 'process' in self.__config__:
if 'repeat' in self.__config__['process']:
self.__repeat__ = int(self.__config__['process']['repeat'])
else:
raise Exception('ExperimentProcess','no repeats field found in process section of workfile')
if 'runs' in self.__config__['process']:
runs = int(self.__config__['process']['runs'])
else:
raise Exception('ExperimentProcess','no runs field found in process section of workfile')
else:
raise Exception('ExperimentProcess','no process section found in workfile')
self.__first__ = False
self.__parameters__ = int( runs / self.__repeat__ )
self.display( OUTPUT_MAJOR, '%s initialized for %d parameters totalling %d runs' % (self.__config__['process']['config'], self.__parameters__, runs) )
self.__queueAnalysis__()
示例12: __init__
def __init__(self, name , priority, message, numero):
Process.__init__(self, name, 4, priority)
self.message = message
self.numero = numero
self.timer = int(0.02* len(message))+1
# 0 no usa , 1 usa , 2 bloquea
self.external = {'Pantalla': 0, 'Audifono': 1, 'Microfono': 0, 'GPS': 0, 'Enviar Info': 1, 'Recibir Info': 1}
示例13: __init__
def __init__(self, env, id, config):
Process.__init__(self, env, id)
self.slot_in = self.slot_out = 1
self.proposals = {}
self.decisions = {}
self.requests = []
self.config = config
self.env.addProc(self)
示例14: __init__
def __init__(self, env, me, leader, acceptors, ballot_number):
Process.__init__(self)
self.env = env
self.me = me
self.leader = leader
self.acceptors = acceptors
self.ballot_number = ballot_number
self.env.addProc(self)
示例15: compile
def compile(self):
"""Run the compiler and return the stdout"""
flags = [self.compiler] + self.flags + [self.main_file]
process = Process(flags)
stdout = process.read_stdout()
return stdout