Last change
on this file since 67:4303a45e8a2f was 58:b24ccde3e229, checked in by Borja Lopez <borja@…>, 10 years ago |
Use a config file for the setup of certain parameters, instead of
hardcoded global variables (ugh!)
|
|
File size:
961 bytes
|
Rev | Line | |
---|
[0] | 1 | #!/usr/bin/env python
|
---|
| 2 |
|
---|
| 3 | import sys
|
---|
| 4 | from datetime import datetime
|
---|
[58] | 5 | from stamper import Stamper
|
---|
[0] | 6 |
|
---|
| 7 |
|
---|
| 8 | def usage(name):
|
---|
| 9 | msg = """
|
---|
| 10 | Usage:
|
---|
| 11 |
|
---|
| 12 | To start tracking time: %(name)s
|
---|
| 13 |
|
---|
| 14 | To record time for a given task: %(name)s customer action
|
---|
| 15 | """ % {'name': name}
|
---|
| 16 | print(msg)
|
---|
| 17 |
|
---|
| 18 |
|
---|
| 19 | if __name__ == '__main__':
|
---|
| 20 |
|
---|
| 21 | s = Stamper()
|
---|
| 22 | s.load_stamps()
|
---|
| 23 |
|
---|
| 24 | if len(sys.argv) == 1:
|
---|
| 25 | # stamp!
|
---|
[58] | 26 | s.stamp(datetime.today().strftime(s.datetime_format),
|
---|
[27] | 27 | None, None, None)
|
---|
[0] | 28 |
|
---|
[35] | 29 | elif len(sys.argv) >= 3:
|
---|
[0] | 30 | # record!
|
---|
| 31 | last_stamp = s.last_stamp()
|
---|
| 32 | current_start = last_stamp['end']
|
---|
| 33 | if not current_start:
|
---|
| 34 | current_start = last_stamp['start']
|
---|
[33] | 35 | customer = sys.argv[1]
|
---|
| 36 | description = ' '.join(sys.argv[2:])
|
---|
[58] | 37 | s.stamp(current_start, datetime.today().strftime(s.datetime_format),
|
---|
[33] | 38 | customer, description)
|
---|
[0] | 39 |
|
---|
| 40 | else:
|
---|
| 41 | usage(sys.argv[0])
|
---|
| 42 | sys.exit(1)
|
---|
| 43 |
|
---|
| 44 | s.save_stamps()
|
---|
Note:
See
TracBrowser
for help on using the repository browser.