Mercurial > getan
annotate contrib/zeiterfassung @ 116:67a89439e10d
Add a setup.py script
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Mon, 12 Dec 2011 09:37:39 +0100 |
parents | e7548b8c6dcc |
children |
rev | line source |
---|---|
8
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
3 # |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
4 # zeiterfassung |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
5 # ------------- |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
6 # (c) 2008 by Sascha L. Teichmann <sascha.teichmann@intevation.de> |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
7 # |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
8 # Simple script which generates lines for zeiterfassung.txt files. |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
9 # |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
10 # This is Free Software licensed under the terms of GPLv3 or later. |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
11 # For details see LICENSE coming with the source of 'getan'. |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
12 # |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
13 import os |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
14 import os.path |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
15 import sys |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
16 import getopt |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
17 import re |
10
4f782a05b4dc
contrib/zeiterfassung: Added parameter -e | --encoding=
Sascha L. Teichmann <teichmann@intevation.de>
parents:
9
diff
changeset
|
18 import codecs |
8
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
19 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
20 from pysqlite2 import dbapi2 as db |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
21 |
108
e7548b8c6dcc
Add option to show entries of last week
Björn Ricks <bjoern.ricks@intevation.de>
parents:
61
diff
changeset
|
22 from datetime import date, datetime |
8
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
23 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
24 DEFAULT_DATABASE = "time.db" |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
25 |
57
2f9093b41c5b
user ? per default for zeiterfassung entry type
Björn Ricks <bjoern.ricks@intevation.de>
parents:
51
diff
changeset
|
26 TYPE_OF_ENTRY = "?" |
8
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
27 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
28 WORKPACKAGE = re.compile("^\[(\w*)(\s|\])") |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
29 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
30 USAGE = '''usage: %s <options> |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
31 with <options> |
9
4e8f5545256d
* Applied and completed Stephan Holl's zeiterfassung.bessere-lesbarkeit.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8
diff
changeset
|
32 [--user=|-u <user>] : Name of user, default: $USER |
4e8f5545256d
* Applied and completed Stephan Holl's zeiterfassung.bessere-lesbarkeit.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8
diff
changeset
|
33 [--database=|-d <database>]: getan database, default: time.db |
4e8f5545256d
* Applied and completed Stephan Holl's zeiterfassung.bessere-lesbarkeit.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8
diff
changeset
|
34 [--project=|-p <key>] : Key of output project, default: all |
10
4f782a05b4dc
contrib/zeiterfassung: Added parameter -e | --encoding=
Sascha L. Teichmann <teichmann@intevation.de>
parents:
9
diff
changeset
|
35 [--encoding=|-e encoding] : encoding of output, default: none |
13
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
36 [--week=]|-w <week>] : week of year |
51
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
37 [--year=]|-y <year>] : year |
8
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
38 [--list|-l] : list all projects |
60
9df5d62e6f7e
add switch to show also empty projects
Björn Ricks <bjoern.ricks@intevation.de>
parents:
59
diff
changeset
|
39 [--help|-h] : This text |
108
e7548b8c6dcc
Add option to show entries of last week
Björn Ricks <bjoern.ricks@intevation.de>
parents:
61
diff
changeset
|
40 [--emtpy|-m] : show empty projects |
e7548b8c6dcc
Add option to show entries of last week
Björn Ricks <bjoern.ricks@intevation.de>
parents:
61
diff
changeset
|
41 [--lastweek|-c] : entries of last working week''' |
8
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
42 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
43 LIST_PROJECTS = ''' |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
44 SELECT key, description, active FROM projects |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
45 ''' |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
46 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
47 PROJECT_ID_BY_KEY = ''' |
9
4e8f5545256d
* Applied and completed Stephan Holl's zeiterfassung.bessere-lesbarkeit.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8
diff
changeset
|
48 SELECT id, description FROM projects where key = :key |
8
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
49 ''' |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
50 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
51 ALL_PROJECT_IDS = ''' |
9
4e8f5545256d
* Applied and completed Stephan Holl's zeiterfassung.bessere-lesbarkeit.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8
diff
changeset
|
52 SELECT id, key, description FROM projects |
8
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
53 ''' |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
54 |
13
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
55 WEEK_ENTRIES = ''' |
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
56 SELECT |
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
57 date(start_time) AS t, |
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
58 sum(strftime('%s', stop_time) - strftime('%s', start_time)), |
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
59 'no description' AS description |
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
60 FROM entries |
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
61 WHERE |
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
62 project_id = :project_id AND |
46
5f87604ea5ed
add year option for contrib/zeiterfassung
Bjoern Ricks <bricks@intevation.de>
parents:
16
diff
changeset
|
63 (strftime('%Y', start_time) ) = :year AND |
13
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
64 (description IS NULL or length(description) = 0) -- trim() function is missing |
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
65 AND (strftime('%W', start_time) = :week OR strftime('%W', stop_time) = :week) |
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
66 GROUP BY round(julianday(start_time)) |
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
67 UNION |
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
68 SELECT date(start_time) AS s, strftime('%s', stop_time) - strftime('%s', start_time), description |
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
69 FROM entries |
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
70 WHERE |
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
71 project_id = :project_id AND |
46
5f87604ea5ed
add year option for contrib/zeiterfassung
Bjoern Ricks <bricks@intevation.de>
parents:
16
diff
changeset
|
72 (strftime('%Y', start_time) ) = :year AND |
13
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
73 description IS NOT NULL AND length(description) > 0 |
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
74 AND (strftime('%W', start_time) = :week OR strftime('%W', stop_time) = :week) |
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
75 ORDER BY t |
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
76 ''' |
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
77 |
8
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
78 ENTRIES = ''' |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
79 SELECT |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
80 date(start_time), |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
81 sum(strftime('%s', stop_time) - strftime('%s', start_time)), |
11
feb6bb4427fe
Applied a variation of Stephan Holl's zeiterfassung.non-utf8-chars-in-db.patch to force the encoding given by --encoding=.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
10
diff
changeset
|
82 'no description' AS description |
8
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
83 FROM entries |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
84 WHERE |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
85 project_id = :project_id AND |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
86 (description IS NULL or length(description) = 0) -- trim() function is missing |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
87 GROUP BY round(julianday(start_time)) |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
88 UNION |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
89 SELECT date(start_time), strftime('%s', stop_time) - strftime('%s', start_time), description |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
90 FROM entries |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
91 WHERE |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
92 project_id = :project_id AND |
51
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
93 description IS NOT NULL AND length(description) > 0 |
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
94 ''' |
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
95 |
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
96 ENTRIES_YEAR = ''' |
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
97 SELECT |
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
98 date(start_time), |
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
99 sum(strftime('%s', stop_time) - strftime('%s', start_time)), |
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
100 'no description' AS description |
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
101 FROM entries |
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
102 WHERE |
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
103 project_id = :project_id AND |
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
104 (description IS NULL or length(description) = 0) -- trim() function is missing |
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
105 GROUP BY round(julianday(start_time)) |
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
106 UNION |
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
107 SELECT date(start_time), strftime('%s', stop_time) - strftime('%s', start_time), description |
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
108 FROM entries |
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
109 WHERE |
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
110 project_id = :project_id AND |
46
5f87604ea5ed
add year option for contrib/zeiterfassung
Bjoern Ricks <bricks@intevation.de>
parents:
16
diff
changeset
|
111 (strftime('%Y', start_time) ) = :year AND |
8
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
112 description IS NOT NULL AND length(description) > 0 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
113 ''' |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
114 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
115 def human_time(s): |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
116 h = s / 3600 |
11
feb6bb4427fe
Applied a variation of Stephan Holl's zeiterfassung.non-utf8-chars-in-db.patch to force the encoding given by --encoding=.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
10
diff
changeset
|
117 m = (s % 3600) / 60 |
feb6bb4427fe
Applied a variation of Stephan Holl's zeiterfassung.non-utf8-chars-in-db.patch to force the encoding given by --encoding=.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
10
diff
changeset
|
118 if (s % 60) >= 30: |
8
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
119 m += 1 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
120 if m == 60: |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
121 m = 0 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
122 h += 1 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
123 return "%2d:%02d" % (h, m) |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
124 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
125 class TermError(Exception): |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
126 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
127 def __init__(self, msg): |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
128 Exception.__init__(self) |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
129 self.msg = msg |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
130 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
131 def __str__(self): |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
132 return repr(self.msg) |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
133 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
134 def tolerantClose(c): |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
135 if c: |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
136 try: c.close() |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
137 except: pass |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
138 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
139 def usage(exit_code = 0): |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
140 print USAGE % sys.argv[0] |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
141 sys.exit(exit_code) |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
142 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
143 def main(): |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
144 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
145 database = DEFAULT_DATABASE |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
146 user = None |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
147 list_projects = False |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
148 project = None |
10
4f782a05b4dc
contrib/zeiterfassung: Added parameter -e | --encoding=
Sascha L. Teichmann <teichmann@intevation.de>
parents:
9
diff
changeset
|
149 encoding = None |
13
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
150 week = None |
46
5f87604ea5ed
add year option for contrib/zeiterfassung
Bjoern Ricks <bricks@intevation.de>
parents:
16
diff
changeset
|
151 year = None |
60
9df5d62e6f7e
add switch to show also empty projects
Björn Ricks <bjoern.ricks@intevation.de>
parents:
59
diff
changeset
|
152 empty_proj = False |
8
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
153 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
154 opts, args = getopt.getopt( |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
155 sys.argv[1:], |
108
e7548b8c6dcc
Add option to show entries of last week
Björn Ricks <bjoern.ricks@intevation.de>
parents:
61
diff
changeset
|
156 'd:u:p:e:hl:w:y:mc', |
e7548b8c6dcc
Add option to show entries of last week
Björn Ricks <bjoern.ricks@intevation.de>
parents:
61
diff
changeset
|
157 ['database=', 'user=', 'project=', 'encoding=', 'help', 'list', 'week=', |
e7548b8c6dcc
Add option to show entries of last week
Björn Ricks <bjoern.ricks@intevation.de>
parents:
61
diff
changeset
|
158 'year=', 'empty', 'lastweek']) |
8
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
159 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
160 for opt, val in opts: |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
161 if opt in ("--database", "-d"): |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
162 database = val |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
163 elif opt in ("--user", "-u"): |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
164 user = val |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
165 elif opt in ("--project", "-p"): |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
166 project = val |
10
4f782a05b4dc
contrib/zeiterfassung: Added parameter -e | --encoding=
Sascha L. Teichmann <teichmann@intevation.de>
parents:
9
diff
changeset
|
167 elif opt in ("--encoding", "-e"): |
4f782a05b4dc
contrib/zeiterfassung: Added parameter -e | --encoding=
Sascha L. Teichmann <teichmann@intevation.de>
parents:
9
diff
changeset
|
168 encoding = val |
8
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
169 elif opt in ("--help", "-h"): |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
170 usage() |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
171 elif opt in ("--list", "-l"): |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
172 list_projects = True |
13
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
173 elif opt in ("--week", "-w"): |
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
174 week = val |
108
e7548b8c6dcc
Add option to show entries of last week
Björn Ricks <bjoern.ricks@intevation.de>
parents:
61
diff
changeset
|
175 elif opt in ("--lastweek", "-c") and not week: |
e7548b8c6dcc
Add option to show entries of last week
Björn Ricks <bjoern.ricks@intevation.de>
parents:
61
diff
changeset
|
176 currentweek = datetime.now().isocalendar()[1] |
e7548b8c6dcc
Add option to show entries of last week
Björn Ricks <bjoern.ricks@intevation.de>
parents:
61
diff
changeset
|
177 lastweek = currentweek - 1 |
e7548b8c6dcc
Add option to show entries of last week
Björn Ricks <bjoern.ricks@intevation.de>
parents:
61
diff
changeset
|
178 if lastweek <= 0: |
e7548b8c6dcc
Add option to show entries of last week
Björn Ricks <bjoern.ricks@intevation.de>
parents:
61
diff
changeset
|
179 lastweek = 52 |
e7548b8c6dcc
Add option to show entries of last week
Björn Ricks <bjoern.ricks@intevation.de>
parents:
61
diff
changeset
|
180 week = str(lastweek) |
46
5f87604ea5ed
add year option for contrib/zeiterfassung
Bjoern Ricks <bricks@intevation.de>
parents:
16
diff
changeset
|
181 elif opt in ("--year", "-y"): |
5f87604ea5ed
add year option for contrib/zeiterfassung
Bjoern Ricks <bricks@intevation.de>
parents:
16
diff
changeset
|
182 year = val |
60
9df5d62e6f7e
add switch to show also empty projects
Björn Ricks <bjoern.ricks@intevation.de>
parents:
59
diff
changeset
|
183 elif opt in ("--empty", "-m"): |
9df5d62e6f7e
add switch to show also empty projects
Björn Ricks <bjoern.ricks@intevation.de>
parents:
59
diff
changeset
|
184 empty_proj = True |
8
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
185 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
186 if not user: |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
187 user = os.getenv("USER") |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
188 |
51
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
189 proj_year = year |
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
190 if not proj_year: |
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
191 proj_year = date.today().strftime("%Y") |
46
5f87604ea5ed
add year option for contrib/zeiterfassung
Bjoern Ricks <bricks@intevation.de>
parents:
16
diff
changeset
|
192 |
10
4f782a05b4dc
contrib/zeiterfassung: Added parameter -e | --encoding=
Sascha L. Teichmann <teichmann@intevation.de>
parents:
9
diff
changeset
|
193 if encoding: |
4f782a05b4dc
contrib/zeiterfassung: Added parameter -e | --encoding=
Sascha L. Teichmann <teichmann@intevation.de>
parents:
9
diff
changeset
|
194 Writer = codecs.getwriter(encoding) |
4f782a05b4dc
contrib/zeiterfassung: Added parameter -e | --encoding=
Sascha L. Teichmann <teichmann@intevation.de>
parents:
9
diff
changeset
|
195 sys.stdout = Writer(sys.stdout) |
4f782a05b4dc
contrib/zeiterfassung: Added parameter -e | --encoding=
Sascha L. Teichmann <teichmann@intevation.de>
parents:
9
diff
changeset
|
196 |
8
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
197 if not os.path.isfile(database): |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
198 print >> sys.stderr, "'%s' does not exist or is not a file." % database |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
199 sys.exit(1) |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
200 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
201 con, cur = None, None |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
202 try: |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
203 try: |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
204 con = db.connect(database) |
11
feb6bb4427fe
Applied a variation of Stephan Holl's zeiterfassung.non-utf8-chars-in-db.patch to force the encoding given by --encoding=.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
10
diff
changeset
|
205 if encoding: |
feb6bb4427fe
Applied a variation of Stephan Holl's zeiterfassung.non-utf8-chars-in-db.patch to force the encoding given by --encoding=.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
10
diff
changeset
|
206 con.text_factory = lambda s: s.decode(encoding) |
8
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
207 cur = con.cursor() |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
208 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
209 if list_projects: |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
210 cur.execute(LIST_PROJECTS) |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
211 while True: |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
212 row = cur.fetchone() |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
213 if not row: break |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
214 print "%s %s %s" % (row[0], row[2] and "*" or "-", row[1]) |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
215 else: |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
216 if project: |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
217 cur.execute(PROJECT_ID_BY_KEY, { 'key': project }) |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
218 row = cur.fetchone() |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
219 if row is None: |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
220 raise TermError("There is no project with key '%s'" % project) |
9
4e8f5545256d
* Applied and completed Stephan Holl's zeiterfassung.bessere-lesbarkeit.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8
diff
changeset
|
221 project_ids = [[row[0], project, row[1]]] |
8
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
222 else: |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
223 cur.execute(ALL_PROJECT_IDS); |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
224 project_ids = cur.fetchall() |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
225 |
59
58bfac26a9ff
add displaying of total time in all projects
Björn Ricks <bjoern.ricks@intevation.de>
parents:
58
diff
changeset
|
226 total = 0 |
9
4e8f5545256d
* Applied and completed Stephan Holl's zeiterfassung.bessere-lesbarkeit.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8
diff
changeset
|
227 for project_id, project, proj_desc in project_ids: |
13
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
228 if not week is None: |
51
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
229 cur.execute(WEEK_ENTRIES, {'project_id': project_id, 'week': week, 'year' : proj_year}) |
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
230 elif not year: |
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
231 cur.execute(ENTRIES, {'project_id': project_id}) |
13
e347f0de5e22
Applied Stephan Holl's week-option.patch
Sascha L. Teichmann <teichmann@intevation.de>
parents:
11
diff
changeset
|
232 else: |
51
3f97954868e4
add year option to usage output
Björn Ricks <bjoern.ricks@intevation.de>
parents:
46
diff
changeset
|
233 cur.execute(ENTRIES_YEAR, {'project_id': project_id, 'year':proj_year}) |
58
9826dcbf119f
rename total variable to total_proj because it refects to total time
Björn Ricks <bjoern.ricks@intevation.de>
parents:
57
diff
changeset
|
234 total_proj = 0 |
61
4b58763e75c1
Show project name before time entries
Björn Ricks <bjoern.ricks@intevation.de>
parents:
60
diff
changeset
|
235 row = cur.fetchone() |
4b58763e75c1
Show project name before time entries
Björn Ricks <bjoern.ricks@intevation.de>
parents:
60
diff
changeset
|
236 if row or empty_proj: |
4b58763e75c1
Show project name before time entries
Björn Ricks <bjoern.ricks@intevation.de>
parents:
60
diff
changeset
|
237 print "# project: %s (%s)" % (project, proj_desc) |
4b58763e75c1
Show project name before time entries
Björn Ricks <bjoern.ricks@intevation.de>
parents:
60
diff
changeset
|
238 while row: |
8
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
239 d = date(*map(int, row[0].split('-'))) |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
240 t = max(60, row[1]) |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
241 c = row[2] |
58
9826dcbf119f
rename total variable to total_proj because it refects to total time
Björn Ricks <bjoern.ricks@intevation.de>
parents:
57
diff
changeset
|
242 total_proj += t |
8
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
243 workpackage = "----" |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
244 if c: |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
245 m = WORKPACKAGE.match(c) |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
246 if m: |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
247 workpackage = m.group(1) |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
248 c = c[m.end():].strip() |
46
5f87604ea5ed
add year option for contrib/zeiterfassung
Bjoern Ricks <bricks@intevation.de>
parents:
16
diff
changeset
|
249 c = c.replace('\x1b', '') |
16
22aa74768d97
left justify user sign in zeiterfassung
Thomas Arendsen Hein <thomas@intevation.de>
parents:
13
diff
changeset
|
250 print "%s %sh %s %-3s [%s] %s" % ( |
8
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
251 d.strftime("%d.%m.%Y"), |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
252 human_time(t), |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
253 TYPE_OF_ENTRY, |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
254 user, |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
255 workpackage, |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
256 c) |
61
4b58763e75c1
Show project name before time entries
Björn Ricks <bjoern.ricks@intevation.de>
parents:
60
diff
changeset
|
257 row = cur.fetchone() |
59
58bfac26a9ff
add displaying of total time in all projects
Björn Ricks <bjoern.ricks@intevation.de>
parents:
58
diff
changeset
|
258 total += total_proj |
60
9df5d62e6f7e
add switch to show also empty projects
Björn Ricks <bjoern.ricks@intevation.de>
parents:
59
diff
changeset
|
259 if empty_proj or total_proj > 0: |
9df5d62e6f7e
add switch to show also empty projects
Björn Ricks <bjoern.ricks@intevation.de>
parents:
59
diff
changeset
|
260 print "# total: %sh\n\n" % human_time(total_proj) |
59
58bfac26a9ff
add displaying of total time in all projects
Björn Ricks <bjoern.ricks@intevation.de>
parents:
58
diff
changeset
|
261 print "# total all projects: %sh\n\n" % human_time(total) |
8
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
262 finally: |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
263 tolerantClose(cur) |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
264 tolerantClose(con) |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
265 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
266 except TermError, e: |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
267 print >> sys.stderr, "error: %s" % e.msg |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
268 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
269 if __name__ == '__main__': |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
270 main() |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
271 |
20414d892f04
Added script to generate lines for zeiterfassung.txt
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
272 # vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: |