How to use session_interrupted method in Slash

Best Python code snippet using slash

appman_gui.py

Source:appman_gui.py Github

copy

Full Screen

1#!/usr/bin/python2import os3import appman4import confman5import subprocess as sp6from argparse import ArgumentParser7from ConfigParser import SafeConfigParser8from PyDragonfly import Dragonfly_Module, CMessage, copy_from_msg, copy_to_msg, MT_EXIT, MT_KILL9from time import sleep10import threading11import Dragonfly_config as rc12import re13import wx14import platform15from traits.api import HasTraits, Bool, Enum, Float, Str, List, File, \16 Button, String, Instance17from traitsui.api import Handler, View, Item, UItem, StatusItem, \18 Group, HGroup, VGroup, spring, EnumEditor, ButtonEditor, TextEditor, InstanceEditor19from traitsui.wx.animated_gif_editor import AnimatedGIFEditor20from output_stream import OutputStream21SRC_DIR = os.environ['BCI_MODULES']22CONFIG_DIR = os.environ['BCI_CONFIG']23DATA_DIR = os.environ['BCI_DATA']24def get_dirs(root, exclude=['attic']):25 dirs = []26 for x in os.listdir(root):27 if os.path.isdir(root + '/' + x) and (x[0] != '.'):28 dirs.append(x)29 dirs.sort()30 for dropper in exclude:31 if dropper in dirs:32 dirs.remove(dropper)33 return dirs34class Dragonfly_Read_Thread(threading.Thread):35 def __init__(self, mod, subs, data, callback, timeout):36 super(Dragonfly_Read_Thread, self).__init__()37 self.mod = mod38 self.subs = subs39 self.data = data40 self.callback = callback41 self.timeout = timeout42 self.stoprequest = threading.Event()43 self.result = 044 def get_result(self):45 return self.result46 def stop(self):47 #print "Dragonfly_Read_Thread: Done, exiting.."48 self.stoprequest.set()49 def run(self):50 if self.timeout > 0:51 timeout = self.timeout52 while not self.stoprequest.isSet():53 msg = CMessage()54 rcv = self.mod.ReadMessage(msg, 0)55 if rcv == 1:56 if msg.GetHeader().msg_type in self.subs:57 self.result = self.callback(msg, self.data)58 if self.result == 1:59 self.stop()60 sleep(.010)61 if self.timeout > 0:62 timeout = timeout - 163 if timeout == 0:64 #print "Timout reached"65 self.stoprequest.set()66class SessionManager(HasTraits):67 parent = Instance(wx.Frame)68 config_dirs = get_dirs(CONFIG_DIR, exclude=['default', 'attic'])69 configs = Enum(*config_dirs)70 #monkey_dirs = get_dirs(DATA_DIR, exclude=['VideoLoggerData', 'KingKong'])71 #monkeys = Enum(*monkey_dirs)72 monkeys = Enum(['KingKong', 'Sim'])73 calib_options = {1:'New Calibration', 2:'From Previous Session', 3:'From Specific Session'}74 calib_opts = Enum(calib_options.keys())75 calib_session = Str76 calib_session_list = List77 monkey_label = Str('Monkey:')78 config_label = Str('Configuration:')79 calib_label = Str('Calibration:')80 session_label = Str('Session:')81 rd_thread = Instance(Dragonfly_Read_Thread)82 monkeys_enabled = Bool(True)83 configs_enabled = Bool(True)84 calib_opts_enabled = Bool(True)85 calib_opts_visible = Bool(True)86 calib_session_enabled = Bool(True)87 calib_session_visible = Bool(False)88 start = Button()89 stop = Button()90 config = Button()91 modules = Button()92 kill = Button()93 statusbar_text = output = OutputStream(max_len=3000) #Instance(OutputStream) #Str("Ready")94 start_button_label = Str('Start')95 start_enabled = Bool(True)96 stop_enabled = Bool(True)97 config_enabled = Bool(True)98 modules_enabled = Bool(True)99 kill_enabled = Bool(True)100 session_num = None101 module_id_list = None102 host_id_list = None103 multi_task_config = Bool(False)104 multi_task_file = None105 subscriptions = [rc.MT_PING_ACK, rc.MT_APP_START_COMPLETE, rc.MT_SESSION_CONFIG,106 rc.MT_EXIT_ACK, rc.MT_XM_END_OF_SESSION]107 busy_anim_file = File(SRC_DIR + '/ApplicationControl/busy.gif')108 appman_busy = Bool(False)109 error_icon_file = File(SRC_DIR + '/ApplicationControl/error.gif')110 error_flag = Bool(False)111 running_icon_file = File(SRC_DIR + '/ApplicationControl/running.gif')112 session_starting = Bool(False)113 session_running = Bool(False)114 session_ending = Bool(False)115 session_interrupted = Bool(False)116 #modman_frame = None117 view = View(VGroup(118 HGroup(119 HGroup(120 VGroup(Item(name='config_label', show_label=False, style='readonly'),121 Item(name='configs', label='Session', show_label=False, enabled_when='configs_enabled')),122 VGroup(Item(name='monkey_label', show_label=False, style='readonly'),123 Item(name='monkeys', label='Monkey', show_label=False, enabled_when='monkeys_enabled')),124 VGroup(Item(name='calib_label', show_label=False, style='readonly'),125 Item(name='calib_opts', editor=EnumEditor(values=calib_options), enabled_when='calib_opts_enabled', label='CalibOpt', show_label=False),126 visible_when='calib_opts_visible==True'),127 VGroup(Item(name='session_label', show_label=False, style='readonly'),128 Item(name='calib_session', width=175, editor = EnumEditor(name = 'calib_session_list'), enabled_when='calib_session_enabled', show_label=False),129 visible_when='calib_session_visible==True'),130 springy=True),131 HGroup(132 Item(name='start', editor=ButtonEditor(label_value='start_button_label'), show_label=False, enabled_when='start_enabled'),133 Item(name='stop', show_label=False, enabled_when='stop_enabled', visible_when='stop_visible==True'),134 Item(name='kill', show_label=False, enabled_when='kill_enabled'),135 Item(name='config', show_label=False, enabled_when='config_enabled'),136 #Item(name='modules', show_label=False, enabled_when='modules_enabled')137 ),138 ),139 HGroup(Item(name='busy_anim_file', editor=AnimatedGIFEditor(), show_label=False, visible_when='appman_busy==True'),140 Item(name='running_icon_file', editor=AnimatedGIFEditor(), show_label=False, visible_when='session_running==True'),141 Item(name='error_icon_file', editor=AnimatedGIFEditor(), show_label=False, visible_when='error_flag==True'),142 Item('statusbar_text', editor=InstanceEditor(), show_label=False, resizable=True, height=100, style='custom')) #springy=True,143 #Item(name='statusbar_text', show_label=False, style='custom', resizable=True))144 ))145 #def __init__(self, **traits):146 # HasTraits.__init__(self, **traits)147 def __init__(self):148 super(SessionManager, self).__init__()149 last_app = appman.get_last()150 print last_app151 if last_app is not None:152 self.configs = last_app153 else:154 appman.write_last(self.configs)155 156 self.check_multi_task_config()157 self.get_last_subject()158 def _modules_fired(self):159 import modman160 self.modman_frame = modman.MainWindow(self.parent, -1, self.statusbar_text, self.modman_closing)161 def modman_closing(self):162 print "modman exiting..."163 self.modman_frame = None164 #def modman_update(self):165 # if self.modman_frame is not None:166 # self.modman_frame.update_text(status)167 def update_status(self, status):168 self.statusbar_text.write(status + '\n')169 print "%s" % status170 def _configs_changed(self):171 self.check_multi_task_config()172 self.get_last_subject()173 def _monkeys_changed(self):174 self.update_calib_sessions()175 def _calib_opts_changed(self):176 self.update_calib_sessions()177 def get_last_subject(self):178 last_subject_file = CONFIG_DIR + '/' + self.configs + '/last_subject.txt'179 if os.path.isfile(last_subject_file):180 f = open(last_subject_file, 'r')181 self.monkeys = f.read()182 f.close()183 def check_multi_task_config(self):184 self.multi_task_file = CONFIG_DIR + '/' + self.configs + '/multi_task.config'185 if os.path.isfile(self.multi_task_file):186 self.multi_task_config = True187 self.calib_opts_visible = False188 self.calib_session_visible = False189 else:190 self.multi_task_config = False191 self.calib_opts_visible = True192 self.multi_task_file = None193 self.update_calib_sessions()194 def get_calib_sessions(self):195 try:196 raw_folder = os.path.join(DATA_DIR, self.monkeys, "Raw")197 self.calib_session_list = get_dirs(raw_folder)198 except:199 self.calib_session = ""200 self.calib_session_list = []201 def update_calib_sessions(self):202 if (self.calib_options[self.calib_opts] == "From Previous Session") or \203 (self.calib_options[self.calib_opts] == "From Specific Session"):204 self.get_calib_sessions()205 if not self.calib_session_list:206 self.start_enabled = False207 self.calib_session_visible = False208 else:209 self.start_enabled = True210 self.calib_session_visible = True211 print self.calib_session212 if (self.calib_options[self.calib_opts] == "From Specific Session"):213 self.calib_session_enabled = True214 if self.calib_session not in self.calib_session_list:215 print "here"216 self.calib_session = self.calib_session_list[-1]217 else:218 self.calib_session_enabled = False219 self.calib_session = self.calib_session_list[-1]220 else:221 self.start_enabled = True222 self.calib_session_visible = False223 def connect(self, server):224 self.mod = Dragonfly_Module(0, 0)225 self.mod.ConnectToMMM(server)226 for sub in self.subscriptions:227 self.mod.Subscribe(sub)228 self.mod.SendModuleReady()229 print "Connected to Dragonfly at", server230 def disconnect(self):231 self.mod.DisconnectFromMMM()232 def proc_modules_PING_ACK(self, msg, data):233 result = 0234 mdf = rc.MDF_PING_ACK()235 copy_from_msg(mdf, msg)236 if mdf.module_name in data['module_list']:237 data['module_id_list'][msg.GetHeader().src_mod_id] = mdf.module_name238 data['module_list'].remove(mdf.module_name)239 if not data['module_list']:240 result = 1241 return result242 def proc_hosts_PING_ACK(self, msg, data):243 result = 0244 mdf = rc.MDF_PING_ACK()245 copy_from_msg(mdf, msg)246 module_info = mdf.module_name.split(':')247 248 print module_info249 250 if (module_info[0] == "AppStarter") and (module_info[1] in data['host_list']):251 data['host_id_list'][msg.GetHeader().src_mod_id] = module_info[1]252 data['host_list'].remove(module_info[1])253 if not data['host_list']:254 result = 1255 return result256 def proc_APP_START_COMPLETE(self, msg, data):257 result = 0258 module_id = msg.GetHeader().src_mod_id259 if module_id in data['host_id_list']:260 data['host_id_list'].remove(module_id)261 if not data['host_id_list']:262 result = 1263 return result264 def proc_modules_EXIT_ACK(self, msg, data):265 result = 0266 if msg.GetHeader().src_mod_id in data['module_id_list']:267 del data['module_id_list'][msg.GetHeader().src_mod_id]268 else:269 print "Unexpected module id: {0}".format(msg.GetHeader().src_mod_id)270 if not data['module_id_list']:271 result = 1272 return result273 def proc_MSG_RECEIVED(self, msg, data):274 return 1275 def proc_SESSION_CONFIG(self, msg, data):276 mdf = rc.MDF_SESSION_CONFIG()277 copy_from_msg(mdf, msg)278 m = re.match(".+\.[0]*(\d+)$", mdf.data_dir)279 if m:280 data['session_num'] = m.group(1)281 else:282 data['session_num'] = '???'283 return 1284 def subscribe_to_list(self, subs):285 for sub in subs:286 self.mod.Subscribe(sub)287 return subs288 def send_PING(self, module_name):289 mdf = rc.MDF_PING()290 mdf.module_name = module_name291 msg = CMessage(rc.MT_PING)292 copy_to_msg(mdf, msg)293 #return msg294 self.mod.SendMessage(msg);295 def send_APP_START(self, config):296 mdf = rc.MDF_APP_START()297 mdf.config = config298 msg = CMessage(rc.MT_APP_START)299 copy_to_msg(mdf, msg)300 self.mod.SendMessage(msg)301 def disable_gui(self):302 self.monkeys_enabled = False303 self.calib_session_enabled = False304 self.calib_opts_enabled = False305 self.configs_enabled = False306 def enable_gui(self):307 self.monkeys_enabled = True308 self.calib_opts_enabled = True309 self.configs_enabled = True310 if self.calib_options[self.calib_opts] != "From Previous Session":311 self.calib_session_enabled = True312 def wait_for_dragonfly_thread(self, raise_exception=True):313 while(self.rd_thread.isAlive()):314 wx.Yield()315 if (self.session_starting == False) and (self.session_ending == False) and \316 (self.session_running == False):317 self.rd_thread.stop()318 if raise_exception == True:319 raise RuntimeError('Cancelled')320 sleep(0.010)321 def _config_fired(self):322 #self.modman_frame = None323 try:324 if self.multi_task_config == True:325 root_files = {'MT' : 'multi_task.config'}326 else:327 root_files = {'XM' : 'XM.config', 'appman' : 'appman.conf'}328 frame = confman.MainWindow(self.parent, -1, CONFIG_DIR, self.configs, root_files)329 except (ValueError, IOError) as e:330 self.update_status("%s" % e)331 self.error_flag = True332 def _kill_fired(self):333 dlg = wx.MessageDialog(self.parent,334 "Do you really want to kill all running modules?",335 "Confirm Kill", wx.OK|wx.CANCEL|wx.ICON_QUESTION)336 result = dlg.ShowModal()337 dlg.Destroy()338 if result == wx.ID_OK:339 self.mod.SendSignal(MT_KILL)340 self.error_flag = False341 self.start_enabled = True342 self.module_id_list = None343 #self.kill_enabled = False344 self.update_status("Modules killed")345 def do_stop_modules(self):346 try:347 self.disable_gui()348 self.appman_busy = True349 self.error_flag = False350 self.start_enabled = False351 self.session_running = False352 self.update_status("Stopping modules...")353 self.session_ending = True354 # prep Dragonfly read thread355 data = {'module_id_list': self.module_id_list}356 self.rd_thread = Dragonfly_Read_Thread(self.mod, [rc.MT_EXIT_ACK], data, self.proc_modules_EXIT_ACK, 300)357 self.rd_thread.start()358 appman.stop_modules(self.mod)359 self.wait_for_dragonfly_thread()360 result = self.rd_thread.get_result()361 if result == 0:362 self.kill_enabled = True363 self.update_status("Some modules did not respond: %s" % (', '.join(map(str, self.module_id_list.values()))))364 raise RuntimeError("!! Click KILL to close any modules still running !!")365 if self.session_num is not None:366 self.update_status("Session #%s is terminated" % self.session_num)367 else:368 self.update_status("Session is terminated")369 self.error_flag = False370 self.start_enabled = True371 except RuntimeError, e:372 self.update_status("%s" % e)373 self.error_flag = True374 finally:375 self.enable_gui()376 self.appman_busy = False377 self.session_ending = False378 self.module_id_list = None379 def _stop_fired(self):380 if self.module_id_list is None:381 appman.stop_modules(self.mod)382 self.error_flag = False383 self.start_enabled = True384 #elif (self.multi_task_config == True) and (self.session_running == True):385 elif (self.session_running == True):386 self.session_running = False387 self.session_interrupted = True388 else:389 self.do_stop_modules()390 def _start_fired(self):391 # advance to the next iteration of the multi_task392 if (self.multi_task_config == True) and (self.session_running == True):393 self.session_running = False394 # cancel starting session395 elif self.session_starting == True:396 self.session_starting = False397 # start new session398 else:399 try:400 self.disable_gui()401 self.appman_busy = True402 self.error_flag = False403 self.start_button_label = 'Cancel'404 self.stop_enabled = False405 #self.kill_enabled = False406 self.session_starting = True407 self.session_num = None408 self.session_interrupted = False409 self.statusbar_text.reset()410 self.update_status("Starting new session...")411 # prepare session parameters412 subject = self.monkeys413 config_list = []414 calib_session_id_list = []415 num_reps_list =[]416 self.update_calib_sessions()417 if self.multi_task_config == True:418 parser = SafeConfigParser()419 parser.read(self.multi_task_file)420 config = dict(parser.items('config'))421 config_list = re.sub(r"[\n\r]+", '', config['config_names']).split(',')422 calib_session_id_list = re.sub(r"[\n\r]+", '', config['calibration_session_ids']).split(',')423 num_reps_list = re.sub(r"[\n\r]+", '', config['num_reps']).split(',')424 else:425 config_list.append(self.configs)426 num_reps_list.append(0)427 if (self.calib_options[self.calib_opts] == "From Specific Session"):428 m = re.match("(\w+)\.DK\.[0]+(\d+)", self.calib_session)429 calib_session_id = int(m.group(2))430 elif (self.calib_options[self.calib_opts] == "From Previous Session"):431 m = re.match("(\w+)\.DK\.[0]+(\d+)", self.calib_session_list[-1])432 calib_session_id = int(m.group(2))433 else:434 calib_session_id = 0435 calib_session_id_list.append(calib_session_id)436 #done = False # put "done" back if you want to repeat forever437 #while not done:438 for c, config in enumerate(config_list):439 hosts = appman.get_host_modules(config)440 # ------------------------------------------------------------------------441 # PING all AppStarter modules442 # ------------------------------------------------------------------------443 self.update_status("Pinging AppStarter modules...")444 host_list = hosts.keys()445 self.host_id_list = {};446 print host_list447 # prep Dragonfly read thread448 data = {'host_list': host_list, 'host_id_list': self.host_id_list}449 self.rd_thread = Dragonfly_Read_Thread(self.mod, [rc.MT_PING_ACK], data, self.proc_hosts_PING_ACK, 400)450 self.rd_thread.start()451 self.send_PING("AppStarter")452 self.wait_for_dragonfly_thread()453 result = self.rd_thread.get_result()454 if result == 0:455 raise RuntimeError('Did not receive response from AppStarter on hosts: %s' % (', '.join(map(str, host_list))))456 # ------------------------------------------------------------------------457 # Send APP_START signal to AppStarter modules458 # ------------------------------------------------------------------------459 self.update_status("Starting modules...")460 # prep Dragonfly read thread461 data = {'host_id_list': self.host_id_list.keys()}462 self.rd_thread = Dragonfly_Read_Thread(self.mod, [rc.MT_APP_START_COMPLETE], data, self.proc_APP_START_COMPLETE, 300)463 self.rd_thread.start()464 self.send_APP_START(config)465 self.wait_for_dragonfly_thread()466 result = self.rd_thread.get_result()467 if result == 0:468 raise RuntimeError('Did not receive APP_START_COMPLETE from all hosts')469 # ------------------------------------------------------------------------470 # PING all modules, make sure they are all running and responding471 # ------------------------------------------------------------------------472 self.update_status("Pinging modules..")473 num_retries = 50474 self.module_id_list = {};475 module_list = []476 for h in hosts.keys():477 module_list = module_list + hosts[h]478 for r in reversed(range(num_retries)):479 # prep Dragonfly read thread480 data = {'module_list': module_list, 'module_id_list': self.module_id_list}481 self.rd_thread = Dragonfly_Read_Thread(self.mod, [rc.MT_PING_ACK], data, self.proc_modules_PING_ACK, 75)482 self.rd_thread.start()483 self.send_PING("*")484 self.wait_for_dragonfly_thread()485 result = self.rd_thread.get_result()486 if result == 0:487 if r == 0:488 raise RuntimeError("Did not receive response from modules: %s" % (', '.join(map(str, module_list))))489 else:490 break491 # ------------------------------------------------------------------------492 # wait for SESSION_CONFIG from executive if it's in appman.conf493 # ------------------------------------------------------------------------494 for m in self.module_id_list.values():495 matched = re.search('^(executive)', m)496 if matched:497 break498 if matched:499 self.update_status("Waiting for SESSION_CONFIG from executive...")500 # prep Dragonfly read thread501 data = {'session_num': ''}502 self.rd_thread = Dragonfly_Read_Thread(self.mod, [rc.MT_SESSION_CONFIG], data, self.proc_SESSION_CONFIG, -1)503 self.rd_thread.start()504 # send the executive extra params it needs505 num_reps = int(num_reps_list[c])506 calib_sess_id = int(calib_session_id_list[c])507 mdf = rc.MDF_XM_START_SESSION()508 mdf.subject_name = subject509 if num_reps > 0:510 mdf.num_reps = num_reps511 if calib_sess_id > 0:512 mdf.calib_session_id = calib_sess_id513 mdf.load_calibration = 1514 msg = CMessage(rc.MT_XM_START_SESSION)515 copy_to_msg(mdf, msg)516 self.mod.SendMessage(msg)517 self.wait_for_dragonfly_thread()518 result = self.rd_thread.get_result()519 if result == 0:520 raise RuntimeError('Did not receive SESSION_CONFIG from executive')521 self.session_num = self.rd_thread.data['session_num']522 #523 # All steps were successful...524 #525 appman.write_last(self.configs)526 if self.multi_task_config == True:527 self.update_status("Multi task session: Session #%s, Config '%s', NumReps %s" % (self.session_num, config, num_reps_list[c]))528 self.disable_gui()529 self.session_running = True530 #531 self.appman_busy = False532 self.start_button_label = 'Next'533 self.session_starting = False534 self.stop_enabled = True535 # wait for session to end or user to hit cancel536 self.rd_thread = Dragonfly_Read_Thread(self.mod, [rc.MT_XM_END_OF_SESSION], None, self.proc_MSG_RECEIVED, -1)537 self.rd_thread.start()538 self.wait_for_dragonfly_thread(False)539 # stop all modules and move onto the next iteration540 self.do_stop_modules()541 if self.session_interrupted == True:542 #done = True543 self.update_status("Multi task session is terminated")544 break;545 # reinit variables for another iteration546 self.appman_busy = True547 self.session_running = False548 self.session_starting = True549 self.start_button_label = 'Cancel'550 self.stop_enabled = False551 #self.kill_enabled = False552 self.session_num = None553 else:554 #done = True555 if self.session_num is None:556 self.update_status("Session is running")557 else:558 self.update_status("Session #%s is running" % self.session_num)559 self.disable_gui()560 self.session_running = True561 self.start_enabled = False562 self.appman_busy = False563 self.session_starting = False564 self.stop_enabled = True565 # wait for session to end or user to hit stop566 self.rd_thread = Dragonfly_Read_Thread(self.mod, [rc.MT_XM_END_OF_SESSION], None, self.proc_MSG_RECEIVED, -1)567 self.rd_thread.start()568 self.wait_for_dragonfly_thread(False)569 if self.session_interrupted == True:570 #done = True571 break;572 if self.multi_task_config == True:573 self.update_status("Multi task session is completed, terminating..")574 else:575 if self.session_interrupted == False:576 self.update_status("Session is completed, terminating..")577 self.do_stop_modules()578 except (RuntimeError, ValueError) as e:579 self.update_status("%s" % e)580 self.error_flag = True581 if e.message == "Cancelled":582 self.update_status("!! Click STOP or KILL to close any modules that already started running ..")583 self.start_enabled = False584 self.kill_enabled = True585 finally:586 self.enable_gui()587 self.appman_busy = False588 self.start_button_label = 'Start'589 self.session_starting = False590 self.stop_enabled = True591 self.session_running = False592class MainWindow(wx.Frame):593 def __init__(self, mm_ip): #, sm):594 wx.Frame.__init__(self, None, -1, 'Application Manager', wx.DefaultPosition, \595 wx.DefaultSize, wx.CAPTION|wx.CLOSE_BOX|wx.SYSTEM_MENU|wx.RESIZE_BORDER|wx.MINIMIZE_BOX)596 self.sm = SessionManager()597 self.sm.connect(mm_ip)598 self.sm.parent = self599 self.sm.edit_traits(parent=self, kind='subpanel')600 self.Fit()601 self.Show(True)602 self.Bind(wx.EVT_CLOSE, self.OnClose)603 def OnClose(self, event):604 if self.sm.session_running == True:605 dlg = wx.MessageDialog(self,606 "There is a session running. Do you really want to exit?",607 "Confirm Exit", wx.OK|wx.CANCEL|wx.ICON_QUESTION)608 result = dlg.ShowModal()609 dlg.Destroy()610 if result == wx.ID_OK:611 self.doClose()612 else:613 self.doClose()614 def doClose(self):615 self.Destroy()616 self.sm.disconnect()617if __name__ == "__main__":618 parser = ArgumentParser(description = "Starts session modules")619 parser.add_argument(type=str, dest='mm_ip', nargs='?', default='127.0.0.1:7111')620 args = parser.parse_args()621 print("Using MM IP=%s" % (args.mm_ip))622 app = wx.App(False)623 frame = MainWindow(args.mm_ip)...

Full Screen

Full Screen

parallel_manager.py

Source:parallel_manager.py Github

copy

Full Screen

...110 self.check_no_requests_timeout()111 time.sleep(TIME_BETWEEN_CHECKS)112 except INTERRUPTION_EXCEPTIONS:113 _logger.error("Server interrupted, stopping workers and terminating", extra={'capture': False})114 get_xmlrpc_proxy(config.root.parallel.server_addr, self.server.port).session_interrupted()115 self.kill_workers()116 raise117 finally:118 for worker in list(self.workers.values()):119 worker.wait_to_finish()120 get_xmlrpc_proxy(config.root.parallel.server_addr, self.server.port).stop_serve()121 get_xmlrpc_proxy(config.root.parallel.server_addr, self.keepalive_server.port).stop_serve()122 self.server_thread.join()...

Full Screen

Full Screen

login_message.py

Source:login_message.py Github

copy

Full Screen

1"""2Message strings used by the login pages and associated authentication logic.3"""4from __future__ import unicode_literals5from __future__ import absolute_import, division, print_function6__author__ = "Graham Klyne (GK@ACM.ORG)"7__copyright__ = "Copyright 2016, G. Klyne"8__license__ = "MIT (http://opensource.org/licenses/MIT)"9import logging10log = logging.getLogger(__name__)11USER_ID_SYNTAX = "User ID must consist of letters, digits and '_' chacacters (%s)"12UNRECOGNIZED_PROVIDER = "Unrecognized provider mechanism `%s` in %s"13USER_NOT_AUTHENTICATED = "User '%s' was not authenticated by %s login service"14USER_NO_EMAIL = "No email address associated with authenticated user %s"15USER_WRONG_EMAIL = "Authenticated user %s email address mismatch (%s, %s)"16USER_WRONG_PASSWORD = "Login as %s: no such user or incorrect password"17USER_ACCOUNT_DISABLED = "Account %s has been disabled"18SESSION_INTERRUPTED = "Session data missing (try login again)"...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Slash automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful