def load_invent_client(self): # Loads invent client. # Like singleton, doesn't construct unless valid login if self._invent_client: return True invent = None dialog = self._xrc.LoadDialog(self, 'username_password_dialog') xrc.XRCCTRL(dialog, 'login_text').Wrap(300) dialog.Layout() dialog.Fit() username_ctrl = xrc.XRCCTRL(dialog, 'username') password_ctrl = xrc.XRCCTRL(dialog, 'password') username_ctrl.SetFocus() username_ctrl.SetMinSize(wx.Size(200, -1)) password_ctrl.SetMinSize(wx.Size(200, -1)) while True: if (dialog.ShowModal() == wx.ID_OK): username = username_ctrl.GetValue() password = password_ctrl.GetValue() invent = Invent(username, password) if (invent.login() == False): wx.MessageBox('Please enter a valid username and password.', 'Valid Login Required', wx.OK|wx.ICON_ERROR, self) else: self._invent_client = invent return True else: return False # User doesn't want to log in return False
def login_to_invent(self): dialog = self._res.LoadDialog(self, 'username_password_dialog') xrc.XRCCTRL(dialog, 'text').Wrap(300) dialog.Layout() dialog.Fit() username_ctrl = xrc.XRCCTRL(dialog, 'username') password_ctrl = xrc.XRCCTRL(dialog, 'password') username_ctrl.SetFocus() # These values don't come through in the xrc file username_ctrl.SetMinSize(wx.Size(200, -1)) password_ctrl.SetMinSize(wx.Size(200, -1)) if (dialog.ShowModal() == wx.ID_OK): username = username_ctrl.GetValue() password = password_ctrl.GetValue() invent = Invent(username, password) if (invent.login() == False): return self.login_to_invent() rospy.set_param('/invent/username', username) rospy.set_param('/invent/password', password) return True else: return False
def get_inventory_object(self): username = rospy.get_param('/invent/username', '') password = rospy.get_param('/invent/password', '') if (username != None and password != None): invent = Invent(username, password) if (invent.login() == True): return invent rospy.set_param('/invent/username', '') rospy.set_param('/invent/password', '') if not self.login_to_invent(): return None else: return Invent(username, password)
class MCBProgramConfig: def __init__(self, expected): rospy.init_node('mcb_prog_conf') self.done_service = rospy.ServiceProxy('prestartup_done', ScriptDone) self.confirm_proxy = rospy.ServiceProxy('mcb_conf_results', ConfirmConf) self.has_finished = False username = rospy.get_param('/invent/username', None) password = rospy.get_param('/invent/password', None) if username == None or password == None: self.finished(False, 'Invalid username or password.') return self.invent = Invent(username, password) if not self.invent.login(): self.finished(False, 'Unable to login to invent.') return self.expected = expected self.serials = [] def finished(self, pass_bool, msg = ''): if self.has_finished: return try: result = ScriptDoneRequest() if pass_bool: result.result = 0 # OK else: result.result = 1 # Fail result.failure_msg = msg rospy.wait_for_service('prestartup_done', 10) self.done_service.call(result) self.has_finished = True except Exception, e: rospy.logerr(traceback.format_exc())
result_service.call(r) exit(retval) try: # Get inventory password from qualification username = getparam('/invent/username') password = getparam('/invent/password') barcode = getparam('qual_item/serial') cameraname = getparam('~camera_name') cameraip = getparam('~camera_ip') progip = getparam('~programming_ip') # Fail if invalid username/password i = Invent(username, password) if not i.login(): failed("Could not connect to invent.") # Get camera url try: camera_url = i.getItemReferences(barcode)["camera_url"] if camera_url == '': raise KeyError except KeyError: failed( "Could not get camera url from invent. Try setting the serial and MAC" ) # Set the camera's name p = subprocess.Popen([ "rosrun", "wge100_camera", "set_name", camera_url + "@" + progip,