1.2.3
by Luca Falavigna
Import upstream version 0.2 |
1 |
#!/usr/bin/env python
|
2 |
# -*- coding:utf-8 -*-
|
|
3 |
||
4 |
# -----------------------------------------------------------------------------
|
|
5 |
# Getting Things Gnome! - A personal organizer for the GNOME desktop
|
|
6 |
# Copyright (c) 2008,2009 Lionel Dricot & Bertrand Rousseau
|
|
7 |
#
|
|
8 |
# This program is free software: you can redistribute it and/or modify it under
|
|
9 |
# the terms of the GNU General Public License as published by the Free Software
|
|
10 |
# Foundation, either version 3 of the License, or (at your option) any later
|
|
11 |
# version.
|
|
12 |
#
|
|
13 |
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
14 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
15 |
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
16 |
# details.
|
|
17 |
#
|
|
18 |
# You should have received a copy of the GNU General Public License along with
|
|
19 |
# this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20 |
# -----------------------------------------------------------------------------
|
|
21 |
||
22 |
"""
|
|
23 |
This script create a new task and launch the editor to display it. GTG should be running
|
|
24 |
"""
|
|
25 |
||
1.2.5
by Luca Falavigna
Import upstream version 0.2.2 |
26 |
import re |
27 |
import sys |
|
1.2.3
by Luca Falavigna
Import upstream version 0.2 |
28 |
import dbus |
1.2.5
by Luca Falavigna
Import upstream version 0.2.2 |
29 |
import cgi |
30 |
import getopt |
|
31 |
from GTG import _ |
|
1.2.3
by Luca Falavigna
Import upstream version 0.2 |
32 |
|
1.2.5
by Luca Falavigna
Import upstream version 0.2.2 |
33 |
def get_task(title, body) : |
1.2.3
by Luca Falavigna
Import upstream version 0.2 |
34 |
#We will connect on the session bus
|
35 |
bus = dbus.SessionBus() |
|
36 |
liste = bus.list_names() |
|
1.2.5
by Luca Falavigna
Import upstream version 0.2.2 |
37 |
busname = "org.GTG" |
38 |
remote_object = bus.get_object(busname,"/org/GTG") |
|
39 |
timi = dbus.Interface(remote_object,dbus_interface="org.GTG") |
|
40 |
#Calling the method
|
|
41 |
timi.open_new_task(title, body) |
|
42 |
||
43 |
def usage(): |
|
44 |
print _("Usage: %s [-i | --interactive] [-h | --help]") % sys.argv[0] |
|
45 |
||
46 |
if __name__ == '__main__': |
|
47 |
interactive = False |
|
48 |
#Command line options handling
|
|
49 |
try: |
|
50 |
opts, args = getopt.getopt(sys.argv[1:], "hi", ["help", "interactive"]) |
|
51 |
except getopt.GetoptError, err: |
|
52 |
# print help information and exit:
|
|
53 |
print str(err) # will print something like "option -a not recognized" |
|
54 |
usage() |
|
55 |
sys.exit(2) |
|
56 |
for o, a in opts: |
|
57 |
if o in ("-i", "--interactive"): |
|
58 |
interactive = True |
|
59 |
elif o in ("-h", "--help"): |
|
60 |
usage() |
|
61 |
sys.exit() |
|
62 |
else: |
|
63 |
assert False, "unhandled option" |
|
64 |
||
65 |
title = " ".join(args) |
|
66 |
if interactive: |
|
67 |
optlist, args = getopt.getopt(args, 'i::') |
|
68 |
body = sys.stdin.read() |
|
69 |
subject_regex = re.compile("^Subject: (.*)$", re.M | re.I) |
|
70 |
if subject_regex.search(body): |
|
71 |
subject = subject_regex.findall(body)[0] |
|
72 |
title = title + ": " + subject |
|
1.2.3
by Luca Falavigna
Import upstream version 0.2 |
73 |
else: |
1.2.5
by Luca Falavigna
Import upstream version 0.2.2 |
74 |
body = "" |
75 |
get_task(title, cgi.escape(body)) |
|
76 |
||
77 |