コード例 #1
0
ファイル: cli.py プロジェクト: tijmengit/pycopia
 def add(self, argv):
     """add [--first_name=<firstname> --last_name=<lastname>] <username>
 Add a new user to the database."""
     args, kwargs = CLI.breakout_args(argv[1:], self._environ)
     username = args[0]
     try:
         pwent = passwd.getpwnam(username)
     except KeyError:
         pass
     else:
         models.create_user(_session, pwent)
         return
     grp = _session.query(models.Group).filter(models.Group.name=="testers").one()
     kwargs["username"] = username
     kwargs["authservice"] = "local"
     kwargs.setdefault("is_staff", True)
     kwargs.setdefault("is_active", True)
     kwargs.setdefault("is_superuser", False)
     if "first_name" not in kwargs:
         kwargs["first_name"] = self._user_input("First Name? ")
     if "last_name" not in kwargs:
         kwargs["last_name"] = self._user_input("Last Name? ")
     user = models.create(models.User, **kwargs)
     user.groups = [grp]
     _session.add(user)
     _session.commit()
コード例 #2
0
ファイル: RemoteCLI.py プロジェクト: animeshinvinci/pycopia
 def win32(self, argv):
     """win32 <funcname> args...
 Calls the win32api function named <funcname> with the supplied arguments and return the results."""
     funcname = argv[1]
     args, kwargs = CLI.breakout_args(argv[2:], vars(self._client))
     rv = self._client.win32(funcname, *args, **kwargs)
     return rv
コード例 #3
0
ファイル: cli.py プロジェクト: tijmengit/pycopia
 def add(self, argv):
     """add column=value ...
 Add a new row."""
     args, kwargs = CLI.breakout_args(argv[1:], self._environ)
     inst = self._obj(*args, **kwargs)
     _session.add(inst)
     _session.commit()
コード例 #4
0
 def win32(self, argv):
     """win32 <funcname> args...
 Calls the win32api function named <funcname> with the supplied arguments and return the results."""
     funcname = argv[1]
     args, kwargs = CLI.breakout_args(argv[2:], vars(self._obj))
     rv = self._obj.win32(funcname, *args, **kwargs)
     return rv
コード例 #5
0
ファイル: RemoteCLI.py プロジェクト: animeshinvinci/pycopia
 def _generic_call(self, argv):
     meth = getattr(self._client, argv[0])
     args, kwargs = CLI.breakout_args(argv[1:], vars(self._client))
     rv = apply(meth, args, kwargs)
     if rv:
         self._print(rv)
     return rv
コード例 #6
0
 def _generic_call(self, argv):
     meth = getattr(self._obj, argv[0])
     args, kwargs = CLI.breakout_args(argv[1:], vars(self._obj))
     rv = meth(*args, **kwargs)
     if rv:
         self._print(rv)
     return rv
コード例 #7
0
ファイル: remote_cli.py プロジェクト: kdart/pycopia3
 def _generic_call(self, argv):
     meth = getattr(self._obj, argv[0])
     args, kwargs = CLI.breakout_args(argv[1:], vars(self._obj))
     rv = meth(*args, **kwargs)
     if rv:
         self._print(rv)
     return rv
コード例 #8
0
 def _generic_call(self, argv):
     meth = getattr(self._client, argv[0])
     args, kwargs = CLI.breakout_args(argv[1:], vars(self._client))
     rv = apply(meth, args, kwargs)
     if rv:
         self._print(rv)
     return rv
コード例 #9
0
ファイル: cli.py プロジェクト: tijmengit/pycopia
 def filter(self, argv):
     """filter
 Apply filters by keyword arguments."""
     args, kwargs = CLI.breakout_args(argv[1:], vars(self._obj))
     if args:
         self._obj = self._obj.filter(" ".join(args))
     if kwargs:
         for k, v in kwargs.iteritems():
             self._obj = self._obj.filter(getattr(self._obj, k) == v)
コード例 #10
0
ファイル: RemoteCLI.py プロジェクト: animeshinvinci/pycopia
 def fiddle(self, argv):
     """fiddle <handle>
 fiddle with a remote file object. Provide the handle id obtained from 'flist'."""
     args, kwargs = CLI.breakout_args(argv[1:], vars(self._client))
     if args:
         handle = args[0]
     else:
         handle = self._client.flist()[0]
     finfo = self._client.get_handle_info(handle)
     if finfo:
         cmd = self.clone(FileCommand)
         cmd._setup(self._client, handle, "%s> " % (finfo,))
         raise NewCommand, cmd # signal parser to use new cmd object
     else:
         self._print("No such handle on server.")
コード例 #11
0
 def fiddle(self, argv):
     """fiddle <handle>
 fiddle with a remote file object. Provide the handle id obtained from 'flist'."""
     args, kwargs = CLI.breakout_args(argv[1:], vars(self._obj))
     if args:
         handle = args[0]
     else:
         handle = self._obj.flist()[0]
     finfo = self._obj.get_handle_info(handle)
     if finfo:
         cmd = self.clone(FileCommand)
         cmd._setup(self._obj, handle, "%s> " % (finfo, ))
         raise CLI.NewCommand(cmd)
     else:
         self._print("No such handle on server.")
コード例 #12
0
ファイル: RemoteCLI.py プロジェクト: animeshinvinci/pycopia
 def interact(self, argv):
     """interact <pid>
 Interact with the raw file-like interface of a process. Provide the pid as
 supplied from plist."""
     args, kwargs = CLI.breakout_args(argv[1:], vars(self._client))
     if args:
         handle = int(args[0])
     else:
         handle = self._client.plist()[0]
     pid = self._client.poll(handle)
     if pid:
         cmd = self.clone(ProcCommand)
         cmd._setup(self._client, pid, "pid %s> " % (pid,))
         raise NewCommand, cmd # signal parser to use new cmd object
     else:
         self._print("No such pid on server.")
コード例 #13
0
 def interact(self, argv):
     """interact <pid>
 Interact with the raw file-like interface of a process. Provide the pid as
 supplied from plist."""
     args, kwargs = CLI.breakout_args(argv[1:], vars(self._obj))
     if args:
         pid = int(args[0])
     else:
         pid = self._obj.plist()[0]
     pid = self._obj.poll(pid)
     if pid:
         cmd = self.clone(ProcCommand)
         cmd._setup(self._obj, pid, "pid %s> " % (pid, ))
         raise CLI.NewCommand(cmd)
     else:
         self._print("No such pid on server.")
コード例 #14
0
ファイル: RemoteCLI.py プロジェクト: bharathi26/pycopia
 def interact(self, argv):
     """interact <pid>
 Interact with the raw file-like interface of a process. Provide the pid as
 supplied from plist."""
     args, kwargs = CLI.breakout_args(argv[1:], vars(self._obj))
     if args:
         pid = int(args[0])
     else:
         pid = self._obj.plist()[0]
     pid = self._obj.poll(pid)
     if pid:
         cmd = self.clone(ProcCommand)
         cmd._setup(self._obj, pid, "pid %s> " % (pid,))
         raise CLI.NewCommand, cmd
     else:
         self._print("No such pid on server.")
コード例 #15
0
 def interact(self, argv):
     """interact <pid>
 Interact with the raw file-like interface of a process. Provide the pid as
 supplied from plist."""
     args, kwargs = CLI.breakout_args(argv[1:], vars(self._client))
     if args:
         handle = int(args[0])
     else:
         handle = self._client.plist()[0]
     pid = self._client.poll(handle)
     if pid:
         cmd = self.clone(ProcCommand)
         cmd._setup(self._client, pid, "pid %s> " % (pid, ))
         raise NewCommand, cmd  # signal parser to use new cmd object
     else:
         self._print("No such pid on server.")
コード例 #16
0
ファイル: cli.py プロジェクト: tijmengit/pycopia
 def set(self, argv):
     """set <name>=<value> ...
 Set the column <name> to <value>."""
     args, kwargs = CLI.breakout_args(argv[1:], self._environ)
     for name, value in kwargs.items():
         setattr(self._obj, name, value)