Mercurial > p > roundup > code
comparison roundup/admin.py @ 5979:33a7b10618a6
Add support for -u to roundup-admin
Reimplement -u <login>[:<password>]. This opens the database as the
login and applies expected permissions. It also creates history
entries for the user. Note that the password is unused. The CLI has
full access to the files so a password check is not useful. Left an
edge case is when the login has a : in it. In this case it may not
work as expected. So don't do that.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Thu, 14 Nov 2019 21:37:13 -0500 |
| parents | d0aebd4aec72 |
| children | 3719b01cbe9e |
comparison
equal
deleted
inserted
replaced
| 5978:fefdf5f97c50 | 5979:33a7b10618a6 |
|---|---|
| 119 message = _('Problem: %(message)s\n\n')%locals() | 119 message = _('Problem: %(message)s\n\n')%locals() |
| 120 sys.stdout.write( _("""%(message)sUsage: roundup-admin [options] [<command> <arguments>] | 120 sys.stdout.write( _("""%(message)sUsage: roundup-admin [options] [<command> <arguments>] |
| 121 | 121 |
| 122 Options: | 122 Options: |
| 123 -i instance home -- specify the issue tracker "home directory" to administer | 123 -i instance home -- specify the issue tracker "home directory" to administer |
| 124 -u -- the user[:password] to use for commands | 124 -u -- the user[:password] to use for commands (default admin) |
| 125 -d -- print full designators not just class id numbers | 125 -d -- print full designators not just class id numbers |
| 126 -c -- when outputting lists of data, comma-separate them. | 126 -c -- when outputting lists of data, comma-separate them. |
| 127 Same as '-S ","'. | 127 Same as '-S ","'. |
| 128 -S <string> -- when outputting lists of data, string-separate them | 128 -S <string> -- when outputting lists of data, string-separate them |
| 129 -s -- when outputting lists of data, space-separate them. | 129 -s -- when outputting lists of data, space-separate them. |
| 1558 print(_("Error: Couldn't open tracker: %(message)s")%locals()) | 1558 print(_("Error: Couldn't open tracker: %(message)s")%locals()) |
| 1559 return 1 | 1559 return 1 |
| 1560 | 1560 |
| 1561 # only open the database once! | 1561 # only open the database once! |
| 1562 if not self.db: | 1562 if not self.db: |
| 1563 self.db = tracker.open('admin') | 1563 self.db = tracker.open(self.name) |
| 1564 | 1564 |
| 1565 self.db.tx_Source = 'cli' | 1565 self.db.tx_Source = 'cli' |
| 1566 | 1566 |
| 1567 # do the command | 1567 # do the command |
| 1568 ret = 0 | 1568 ret = 0 |
| 1618 self.usage(str(e)) | 1618 self.usage(str(e)) |
| 1619 return 1 | 1619 return 1 |
| 1620 | 1620 |
| 1621 # handle command-line args | 1621 # handle command-line args |
| 1622 self.tracker_home = os.environ.get('TRACKER_HOME', '') | 1622 self.tracker_home = os.environ.get('TRACKER_HOME', '') |
| 1623 # TODO: reinstate the user/password stuff (-u arg too) | 1623 self.name = 'admin' |
| 1624 name = password = '' | 1624 self.password = '' # unused |
| 1625 if 'ROUNDUP_LOGIN' in os.environ: | 1625 if 'ROUNDUP_LOGIN' in os.environ: |
| 1626 l = os.environ['ROUNDUP_LOGIN'].split(':') | 1626 l = os.environ['ROUNDUP_LOGIN'].split(':') |
| 1627 name = l[0] | 1627 self.name = l[0] |
| 1628 if len(l) > 1: | 1628 if len(l) > 1: |
| 1629 password = l[1] | 1629 self.password = l[1] |
| 1630 self.separator = None | 1630 self.separator = None |
| 1631 self.print_designator = 0 | 1631 self.print_designator = 0 |
| 1632 self.verbose = 0 | 1632 self.verbose = 0 |
| 1633 for opt, arg in opts: | 1633 for opt, arg in opts: |
| 1634 if opt == '-h': | 1634 if opt == '-h': |
| 1656 self.usage('Only one of -c, -S and -s may be specified') | 1656 self.usage('Only one of -c, -S and -s may be specified') |
| 1657 return 1 | 1657 return 1 |
| 1658 self.separator = ' ' | 1658 self.separator = ' ' |
| 1659 elif opt == '-d': | 1659 elif opt == '-d': |
| 1660 self.print_designator = 1 | 1660 self.print_designator = 1 |
| 1661 elif opt == '-u': | |
| 1662 l = arg.split(':') | |
| 1663 self.name = l[0] | |
| 1664 if len(l) > 1: | |
| 1665 self.password = l[1] | |
| 1661 | 1666 |
| 1662 # if no command - go interactive | 1667 # if no command - go interactive |
| 1663 # wrap in a try/finally so we always close off the db | 1668 # wrap in a try/finally so we always close off the db |
| 1664 ret = 0 | 1669 ret = 0 |
| 1665 try: | 1670 try: |
