~ubuntu-branches/ubuntu/vivid/system-config-printer/vivid

« back to all changes in this revision

Viewing changes to troubleshoot/ErrorLogFetch.py

  • Committer: Package Import Robot
  • Author(s): Till Kamppeter
  • Date: 2014-07-06 09:41:43 UTC
  • mfrom: (1.1.81)
  • Revision ID: package-import@ubuntu.com-20140706094143-yvp3kzo7ti1ghih8
Tags: 1.4.5+20140706-0ubuntu1
* New upstream release
   o GIT 1.4.x snapshot from 6 July 2014
   o Some codec fixes
   o Traceback fixes
   o IPv6 address entry fix
   o Auth info saving improvement
   o Some loop/hang bug fixes
   o Use LockButton for fewer auth dialogs
* 30_newprinter-driver-download-override-false-error-alarm.patch,
  33_dont-use-hp-makeuri-with-non-hp-printers.patch:
  Removed, included upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
## Printing troubleshooter
4
4
 
5
 
## Copyright (C) 2008, 2010 Red Hat, Inc.
 
5
## Copyright (C) 2008, 2010, 2014 Red Hat, Inc.
6
6
## Authors:
7
7
##  Tim Waugh <twaugh@redhat.com>
8
8
 
28
28
import time
29
29
from timedops import TimedOperation
30
30
from base import *
 
31
 
 
32
try:
 
33
    from systemd import journal
 
34
except:
 
35
    journal = False
 
36
 
31
37
class ErrorLogFetch(Question):
32
38
    def __init__ (self, troubleshooter):
33
39
        Question.__init__ (self, troubleshooter, "Error log fetch")
38
44
        answers = self.troubleshooter.answers
39
45
        parent = self.troubleshooter.get_window ()
40
46
        self.answers = {}
41
 
        try:
42
 
            checkpoint = answers['error_log_checkpoint']
43
 
        except KeyError:
44
 
            checkpoint = None
 
47
        checkpoint = answers.get ('error_log_checkpoint')
 
48
        cursor = answers.get ('error_log_cursor')
45
49
 
46
 
        if self.persistent_answers.has_key ('error_log'):
 
50
        if (self.persistent_answers.has_key ('error_log') or
 
51
            self.persistent_answers.has_key ('journal')):
47
52
            checkpoint = None
 
53
            cursor = None
48
54
 
49
55
        def fetch_log (c):
50
56
            prompt = c._get_prompt_allowed ()
104
110
            except cups.IPPError:
105
111
                pass
106
112
 
 
113
        self.answers = {}
 
114
        if journal and cursor != None:
 
115
            def journal_format (x):
 
116
                try:
 
117
                    priority = "XACEWNIDd"[x['PRIORITY']]
 
118
                except (IndexError, TypeError):
 
119
                    priority = " "
 
120
 
 
121
                return (priority + " " +
 
122
                        x['__REALTIME_TIMESTAMP'].strftime("[%m/%b/%Y:%T]") +
 
123
                        " " + x['MESSAGE'])
 
124
 
 
125
            r = journal.Reader ()
 
126
            r.seek_cursor (cursor)
 
127
            r.add_match (_COMM="cupsd")
 
128
            self.answers['journal'] = map (journal_format, r)
 
129
 
107
130
        if checkpoint != None:
108
131
            self.op = TimedOperation (fetch_log,
109
132
                                      (self.authconn,),
114
137
                f.seek (checkpoint)
115
138
                lines = f.readlines ()
116
139
                os.remove (tmpfname)
117
 
                self.answers = { 'error_log': map (lambda x: x.strip (),
118
 
                                                   lines) }
 
140
                self.answers['error_log'] = map (lambda x: x.strip (), lines)
119
141
 
120
142
        return False
121
143