Beispiel #1
0
 def add_useroption(self,
                    name=None,
                    default_user=None,
                    default_password=None):
     name2 = ''
     if name is None:
         name = ''
     # because can't reference name=self.name in def
     if not name:
         if 'name' in self.__dict__ and getattr(self, 'name'):
             name = getattr(self, 'name')
         elif 'software' in self.__dict__ and getattr(self, 'software'):
             name = getattr(self, 'software')
     if not default_user and 'default_user' in self.__dict__ and getattr(
             self, 'default_user'):
         default_user = getattr(self, 'default_user')
     if not default_password and 'default_password' in self.__dict__ and getattr(
             self, 'default_password'):
         default_password = getattr(self, 'default_password')
     if not isBlankOrNone(name):
         name2 = "%s " % name
     (user_envs, default_user) = getenvs2(['USERNAME', 'USER'],
                                          default_user, name)
     (pw_envs, default_password) = getenvs2('PASSWORD', default_password,
                                            name)
     self.add_opt('-u',
                  '--user',
                  dest='user',
                  help='%sUsername (%s)' % (name2, user_envs),
                  default=default_user)
     self.add_opt('-p',
                  '--password',
                  dest='password',
                  help='%sPassword (%s)' % (name2, pw_envs),
                  default=default_password)
Beispiel #2
0
 def add_useroption(self, name='', default_user=None, default_password=None):
     name2 = ''
     if not isBlankOrNone(name):
         name2 = "%s " % name
     (user_envs, default_user) = getenvs2(['USERNAME', 'USER'], default_user, name)
     (pw_envs, default_password) = getenvs2('PASSWORD', default_password, name)
     self.add_opt('-u', '--user', dest='user', help='%sUsername (%s)' % (name2, user_envs), default=default_user)
     self.add_opt('-p', '--password', dest='password', help='%sPassword (%s)' % (name2, pw_envs),
                  default=default_password)
Beispiel #3
0
 def add_hostoption(self, name='', default_host=None, default_port=None):
     name2 = ''
     # if isList(name):
     #     name2 = '%s ' % name[0]
     # elif not isBlankOrNone(name):
     if not isBlankOrNone(name):
         name2 = '%s ' % name
     if default_port is not None:
         # assert isPort(default_port)
         if not isPort(default_port):
             raise CodingError('invalid default port supplied to add_hostoption()')
     (host_envs, default_host) = getenvs2('HOST', default_host, name)
     (port_envs, default_port) = getenvs2('PORT', default_port, name)
     self.add_opt('-H', '--host', dest='host', help='%sHost (%s)' % (name2, host_envs), default=default_host)
     self.add_opt('-P', '--port', dest='port', help='%sPort (%s)' % (name2, port_envs), default=default_port)
Beispiel #4
0
 def add_hostoption(self, name=None, default_host=None, default_port=None):
     name2 = ''
     # if isList(name):
     #     name2 = '%s ' % name[0]
     # elif not isBlankOrNone(name):
     if name is None:
         name = ''
     # because can't reference name=self.name in def
     if not name:
         # pylint will fail if you use these directly as it tries to resolve them
         if 'name' in self.__dict__ and getattr(self, 'name'):
             name = getattr(self, 'name')
         elif 'software' in self.__dict__ and getattr(self, 'software'):
             name = getattr(self, 'software')
     if not default_host and 'default_host' in self.__dict__ and getattr(
             self, 'default_host'):
         default_host = getattr(self, 'default_host')
     if not default_port and 'default_port' in self.__dict__ and getattr(
             self, 'default_port'):
         default_port = getattr(self, 'default_port')
     if not isBlankOrNone(name):
         if isList(name):
             name2 = '{0} '.format(name[0])
         else:
             name2 = '{0} '.format(name)
     if default_host is not None and not isHost(default_host):
         raise CodingError(
             'invalid default host supplied to add_hostoption()')
     if default_port is not None and not isPort(default_port):
         raise CodingError(
             'invalid default port supplied to add_hostoption()')
     (host_envs_help, default_host) = getenvs2(my_vars='HOST',
                                               default=default_host,
                                               name=name)
     (port_envs_help, default_port) = getenvs2(my_vars='PORT',
                                               default=default_port,
                                               name=name)
     self.add_opt('-H',
                  '--host',
                  dest='host',
                  help='%sHost (%s)' % (name2, host_envs_help),
                  default=default_host)
     self.add_opt('-P',
                  '--port',
                  dest='port',
                  help='%sPort (%s)' % (name2, port_envs_help),
                  default=default_port)
Beispiel #5
0
 def add_useroption(self, name=None, default_user=None, default_password=None):
     name2 = ''
     if name is None:
         name = ''
     # because can't reference name=self.name in def
     if not name:
         if 'name' in self.__dict__ and getattr(self, 'name'):
             name = getattr(self, 'name')
         elif 'software' in self.__dict__ and getattr(self, 'software'):
             name = getattr(self, 'software')
     if not isBlankOrNone(name):
         name2 = "%s " % name
     (user_envs, default_user) = getenvs2(['USERNAME', 'USER'], default_user, name)
     (pw_envs, default_password) = getenvs2('PASSWORD', default_password, name)
     self.add_opt('-u', '--user', dest='user', help='%sUsername (%s)' % (name2, user_envs), default=default_user)
     self.add_opt('-p', '--password', dest='password', help='%sPassword (%s)' % (name2, pw_envs),
                  default=default_password)
Beispiel #6
0
 def add_hostoption(self, name=None, default_host=None, default_port=None):
     name2 = ''
     # if isList(name):
     #     name2 = '%s ' % name[0]
     # elif not isBlankOrNone(name):
     if name is None:
         name = ''
     # because can't reference name=self.name in def
     if not name:
         # pylint will fail if you use these directly as it tries to resolve them
         if 'name' in self.__dict__ and getattr(self, 'name'):
             name = getattr(self, 'name')
         elif 'software' in self.__dict__ and getattr(self, 'software'):
             name = getattr(self, 'software')
     if not isBlankOrNone(name):
         name2 = '%s ' % name
     if default_port is not None:
         # assert isPort(default_port)
         if not isPort(default_port):
             raise CodingError('invalid default port supplied to add_hostoption()')
     (host_envs, default_host) = getenvs2('HOST', default_host, name)
     (port_envs, default_port) = getenvs2('PORT', default_port, name)
     self.add_opt('-H', '--host', dest='host', help='%sHost (%s)' % (name2, host_envs), default=default_host)
     self.add_opt('-P', '--port', dest='port', help='%sPort (%s)' % (name2, port_envs), default=default_port)