Example #1
0
    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
Example #2
0
  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
Example #3
0
  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)
    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 = []
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 = rospy.ServiceProxy('prestartup_done', ScriptDone)
    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([
    exit(-1)
serial = int(barcode[5:12])

if serial >= 1800000 and serial <= 1800015: # First 15 cameras followed a different system
    serial = serial - 1800000
   
url = "serial://%i"%serial

print "Camera url is:", url

# Get inventory password from qualification
username = rospy.get_param('/invent/username', None)
password = rospy.get_param('/invent/password', None)

# Fail if invalid username/password
i = Invent(username, password)
if not i.login():
    print "Could not connect to invent."
    exit(-1)

# Was this camera already put on invent with a different serial?
# Write camera serial number to invent if it is not already there
try:
    prevserial = i.getItemReferences(barcode)["camera_url"]
    if not prevserial in [ url, '']:
        print "This part was already stored in invent with a different serial '%s'. This should never happen."%prevserial
        exit(-1)
except KeyError:
    prevserial = ''
    pass
Example #8
0
    if val == None:
        print >> sys.stderr, "Parameter %s not set" % name
        exit(-1)
    return val


try:
    print >> sys.stderr, "This node converts the serial number in /qualification/serial into a camera url."

    # Get inventory password from qualification
    username = getparam('/invent/username')
    password = getparam('/invent/password')
    barcode = getparam('qual_item/serial')

    # Fail if invalid username/password
    i = Invent(username, password)
    if not i.login():
        print >> sys.stderr, "Could not connect to invent."
        exit(-1)

    # Get camera url
    try:
        print >> sys.stderr, "Searching for barcode ", barcode
        camera_url = i.getItemReferences(barcode)["camera_url"]
        if camera_url == '':
            raise KeyError
    except KeyError:
        print >> sys.stderr, "Could not get camera url from invent in wge100_get_url.py"
        exit(-1)

    myargv = rospy.client.myargv()