12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- "all mac os related classes"
- from pwman.ui.cli import PwmanCli
- from pwman.ui import tools
- import time
- class PwmanCliMac(PwmanCli):
- """
- inherit from PwmanCli, override the right functions...
- """
- def do_copy(self, args):
- ids = self.get_ids(args)
- if len(ids) > 1:
- print "Can only 1 password at a time..."
- try:
- node = self._db.getnodes(ids)
- node[0].get_password()
- tools.text_to_mcclipboard(node[0].get_password())
- print "copied password for {}@{} clipboard".format(
- node[0].get_username(), node[0].get_url())
- time.sleep(10)
- tools.text_to_clipboards("")
- except Exception as e:
- self.error(e)
- def do_cp(self, args):
- self.do_copy(args)
- def do_open(self, args):
- ids = self.get_ids(args)
- if not args:
- self.help_open()
- return
- if len(ids) > 1:
- print "Can open only 1 link at a time ..."
- return None
- try:
- node = self._db.getnodes(ids)
- url = node[0].get_url()
- tools.open_url(url, macosx=True)
- except Exception as e:
- self.error(e)
- def do_o(self, args):
- self.do_open(args)
-
-
-
- def help_open(self):
- self.usage("open <ID>")
- print "Launch default browser with 'open url',\n" \
- + "the url must contain http:// or https://."
- def help_o(self):
- self.help_open()
- def help_copy(self):
- self.usage("copy <ID>")
- print "Copy password to Cocoa clipboard using pbcopy"
- def help_cp(self):
- self.help_copy()
- class PwmanCliMacNew(PwmanCliMac):
- pass
|