Subversion Repositories basico

Rev

Rev 42 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 42 Rev 73
Line 3... Line 3...
3
# File: basico.py
3
# File: basico.py
4
# Author: Tomás Vírseda
4
# Author: Tomás Vírseda
5
# License: GPL v3
5
# License: GPL v3
6
# Description: Main entry point por Basico app
6
# Description: Main entry point por Basico app
7
import os
7
import os
-
 
8
# -*- coding: utf-8 -*-
8
import sys
9
import sys
-
 
10
import codecs
-
 
11
sys.stdout = codecs.getwriter("iso-8859-1")(sys.stdout, 'xmlcharrefreplace')
9
import traceback as tb
12
import traceback as tb
10
import imp
13
import imp
11
import signal
14
import signal
12
from pprint import pprint
15
from pprint import pprint
13
from os.path import abspath, sep as SEP
16
from os.path import abspath, sep as SEP
Line 31... Line 34...
31
from .projects import Projects
34
from .projects import Projects
32
from .tasks import Tasks
35
from .tasks import Tasks
33
from .plugins import Plugins
36
from .plugins import Plugins
34
from .callbacks import Callback
37
from .callbacks import Callback
35
from .notify import Notification
38
from .notify import Notification
36
from .stats import Stats
-
 
-
 
39
#from .stats import Stats
37
from .database import Database
40
from .database import Database
38
from .driver import SeleniumDriver
41
from .driver import SeleniumDriver
39
from .env import ROOT, APP, LPATH, GPATH, FILE
42
from .env import ROOT, APP, LPATH, GPATH, FILE
40
43
41
44
Line 66... Line 69...
66
                'Notify'    :   Notification(),
69
                'Notify'    :   Notification(),
67
                'Tasks'     :   Tasks(),
70
                'Tasks'     :   Tasks(),
68
                'IM'        :   IconManager(),
71
                'IM'        :   IconManager(),
69
                'Plugins'   :   Plugins(),
72
                'Plugins'   :   Plugins(),
70
                'Callbacks' :   Callback(),
73
                'Callbacks' :   Callback(),
71
                'Stats'     :   Stats(),
-
 
-
 
74
                #'Stats'     :   Stats(),
72
                'DB'        :   Database(),
75
                'DB'        :   Database(),
73
                'Driver'    :   SeleniumDriver()
76
                'Driver'    :   SeleniumDriver()
74
            }
77
            }
75
            self.register_services(services)
78
            self.register_services(services)
76
        except Exception as error:
79
        except Exception as error:
Line 224... Line 227...
224
        for name in self.services:
227
        for name in self.services:
225
            try:
228
            try:
226
                if name != 'GUI':
229
                if name != 'GUI':
227
                    self.deregister_service(name)
230
                    self.deregister_service(name)
228
            except Exception as error:
231
            except Exception as error:
229
                self.log.error(error)
-
 
-
 
232
                self.log.error(self.get_traceback())
-
 
233
                raise
230
234
231
        self.log.info("Basico finished")
235
        self.log.info("Basico finished")
232
236
233
237
234
    def get_traceback(self):
238
    def get_traceback(self):
Line 240... Line 244...
240
            self.gui = self.get_service('GUI')
244
            self.gui = self.get_service('GUI')
241
            self.gui.run()
245
            self.gui.run()
242
        except:
246
        except:
243
            self.log.error(self.get_traceback())
247
            self.log.error(self.get_traceback())
244
248
245
-
 
246
    def parse(self):
-
 
247
        utils = self.get_service('Utils')
-
 
248
        content = open('/home/t00m/Documents/devel/svn/basico/branches/BR-0.2-dev/entry.xml', 'r').read()
-
 
249
        f = utils.feedparser_parse(content)
-
 
250
        for entry in f.entries:
-
 
251
            pass
-
 
252
            #~ print (entry)
-
 
253
        #~ pprint(f.entries[0])
-
 
254
        #~ print (f.entries[1].title)
-
 
255
        #~ print (f.entries[1].d_sapnotesnumber_detail['value'])
-
 
256
        #~ print (key, f.entries[0][key])
-
 
257
        #~ for key in f.entries[1]:
-
 
258
            #~ print(key)
-
 
259
            #~ print (key, f.entries[1][key])
-
 
260
        #~ for entry in f:
-
 
261
            #~ print (entry)
-
 
262
            #~ print (entry, f[entry])
-
 
263
        #~ sid = f.entries[0].d_sapnotesnumber
-
 
264
        #~ print (sid)
-
 
265
249
266
def main():
250
def main():
267
    #DOC: http://stackoverflow.com/questions/16410852/keyboard-interrupt-with-with-python-gtk
251
    #DOC: http://stackoverflow.com/questions/16410852/keyboard-interrupt-with-with-python-gtk
268
    signal.signal(signal.SIGINT, signal.SIG_DFL)
252
    signal.signal(signal.SIGINT, signal.SIG_DFL)
269
    basico = Basico()
253
    basico = Basico()
270
    basico.setup()
254
    basico.setup()
271
    #~ basico.parse()
-
 
272
    #~ basico.stop()
-
 
273
    ok = basico.check()
255
    ok = basico.check()
274
    if ok:
256
    if ok:
275
        basico.run()
257
        basico.run()
276
    sys.exit(0)
258
    sys.exit(0)