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

« back to all changes in this revision

Viewing changes to troubleshoot/ErrorLogCheckpoint.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, 2009 Red Hat, Inc.
 
5
## Copyright (C) 2008, 2009, 2014 Red Hat, Inc.
6
6
## Author: Tim Waugh <twaugh@redhat.com>
7
7
 
8
8
## This program is free software; you can redistribute it and/or modify
27
27
import time
28
28
from timedops import TimedOperation, OperationCanceled
29
29
from base import *
 
30
 
 
31
try:
 
32
    from systemd import journal
 
33
except:
 
34
    journal = False
 
35
 
30
36
class ErrorLogCheckpoint(Question):
31
37
    def __init__ (self, troubleshooter):
32
38
        Question.__init__ (self, troubleshooter, "Error log checkpoint")
35
41
                                    "from the CUPS scheduler.  This may "
36
42
                                    "cause the scheduler to restart.  Click "
37
43
                                    "the button below to enable debugging."))
38
 
        button = Gtk.Button (_("Enable Debugging"))
 
44
        button = Gtk.Button.new_with_label (_("Enable Debugging"))
39
45
        buttonbox = Gtk.HButtonBox ()
40
46
        buttonbox.set_border_width (0)
41
47
        buttonbox.set_layout (Gtk.ButtonBoxStyle.START)
54
60
                                            False):
55
61
            return
56
62
 
57
 
        c = self.troubleshooter.answers['_authenticated_connection']
 
63
        f = self.troubleshooter.answers['_authenticated_connection_factory']
 
64
        c = f.get_connection ()
58
65
        c._set_lock (False)
59
66
        settings = c.adminGetServerSettings ()
60
67
        if len (settings.keys ()) == 0:
133
140
                                      args=('/admin/log/error_log', tmpfname),
134
141
                                      parent=parent)
135
142
            self.op.run ()
136
 
        except RuntimeError:
137
 
            try:
138
 
                os.remove (tmpfname)
139
 
            except OSError:
140
 
                pass
141
 
 
142
 
            return self.answers
143
 
        except cups.IPPError:
144
 
            try:
145
 
                os.remove (tmpfname)
146
 
            except OSError:
147
 
                pass
148
 
 
149
 
            return self.answers
150
 
 
151
 
        statbuf = os.stat (tmpfname)
152
 
        os.remove (tmpfname)
 
143
        except (RuntimeError, cups.IPPError):
 
144
            try:
 
145
                os.remove (tmpfname)
 
146
            except OSError:
 
147
                pass
 
148
        except cups.HTTPError, e:
 
149
            try:
 
150
                os.remove (tmpfname)
 
151
            except OSError:
 
152
                pass
 
153
 
 
154
            # Abandon the CUPS connection and make another.
 
155
            answers = self.troubleshooter.answers
 
156
            factory = answers['_authenticated_connection_factory']
 
157
            self.authconn = factory.get_connection ()
 
158
            self.answers['_authenticated_connection'] = self.authconn
 
159
 
 
160
        try:
 
161
            statbuf = os.stat (tmpfname)
 
162
            os.remove (tmpfname)
 
163
        except OSError:
 
164
            statbuf = [0, 0, 0, 0, 0, 0, 0]
 
165
 
153
166
        self.answers['error_log_checkpoint'] = statbuf[6]
154
167
        self.persistent_answers['error_log_checkpoint'] = statbuf[6]
 
168
 
 
169
        if journal:
 
170
            j = journal.Reader ()
 
171
            j.seek_tail ()
 
172
            cursor = j.get_previous ()['__CURSOR']
 
173
            self.answers['error_log_cursor'] = cursor
 
174
            self.persistent_answers['error_log_cursor'] = cursor
 
175
 
155
176
        return self.answers
156
177
 
157
178
    def can_click_forward (self):