Legend:
- Unmodified
- Added
- Removed
-
trunk/config.py
r271 r278 40 40 41 41 if not pynotify.init('Itaka'): 42 print_w arning(_('Pynotify module is failing, disabling notifications'))42 print_w(_('Pynotify module is failing, disabling notifications')) 43 43 notify_available = False 44 44 except ImportError: 45 print_w arning(_('Pynotify module is missing, disabling notifications'))45 print_w(_('Pynotify module is missing, disabling notifications')) 46 46 notify_available = False 47 47 … … 56 56 57 57 if not os.path.exists(image_dir): 58 print_e rror(_('Could not find images directory %s' % (image_dir)))58 print_e(_('Could not find images directory %s' % (image_dir))) 59 59 sys.exit(1) 60 60 … … 116 116 117 117 #: Default configuration sections and values 118 # WARNING: Don't forget to update configuration_dict in uigtk.py if you change this! 118 119 self.default_options = ( 119 120 {'server': ( … … 127 128 ('currentwindow', False), ('scale', False), 128 129 ('scalepercent', 100) 130 )}, 131 132 {'log': ( 133 ('logtimeformat', '[%d/%b/%Y %H:%M:%S]'), 134 ('logfile', '~/.itaka/access.log') 129 135 )}, 130 136 … … 171 177 172 178 except: 173 if console_verbosity['normal']: print_e rror(_('Could not read configuration file (%s)' % (self.config_file)))179 if console_verbosity['normal']: print_e(_('Could not read configuration file (%s)' % (self.config_file))) 174 180 if console_verbosity['debug']: traceback.print_exc() 175 181 … … 196 202 if not configuration_values.has_key(section): 197 203 if not console_verbosity['quiet'] and not brokenwarning: 198 print_w arning(_('Detected old or broken configuration file. Fixing'))204 print_w(_('Upgrading configuration file.')) 199 205 brokenwarning = True 200 206 config_instance.add_section(section) … … 210 216 if not configuration_values[section].has_key(key): 211 217 if not console_verbosity['quiet'] and not brokenwarning: 212 print_w arning(_('Detected old or broken configuration file. Fixing'))218 print_w(_('Detected old or broken configuration file. Fixing')) 213 219 self.update(section, key, val) 214 220 configuration_values[section][key] = val … … 234 240 if console_verbosity['normal']: print_m(_('Saving configuration')) 235 241 except: 236 if not console_verbosity['quiet']: print_e rror(_('Could not write configuration file %s' % (self.config_file)))242 if not console_verbosity['quiet']: print_e(_('Could not write configuration file %s' % (self.config_file))) 237 243 if console_verbosity['debug']: traceback.print_exc() 238 244 … … 255 261 if console_verbosity['debug']: print_m(_("Updating configuration key '%(key)s' to '%(value)s'") % {'key': key, 'value': value}) 256 262 except: 257 if not console_verbosity['quiet']: print_e rror(_('Could not write configuration file %s' % (self.config_file)))263 if not console_verbosity['quiet']: print_e(_('Could not write configuration file %s' % (self.config_file))) 258 264 if console_verbosity['debug']: traceback.print_exc() 259 265 … … 282 288 config_instance.write(open(path, 'w')) 283 289 except: 284 if not console_verbosity['quiet']: print_e rror(_('Could not write configuration file %s' % (path)))290 if not console_verbosity['quiet']: print_e(_('Could not write configuration file %s' % (path))) 285 291 if console_verbosity['debug']: traceback.print_exc() 286 292 -
trunk/console.py
r277 r278 66 66 print_message('DEBUG: %s' % (" - ".join(str(item) for item in strings))) 67 67 68 def print_type(*strings): 69 """ 70 Print type wrapper. 71 72 @type *strings: anything 73 @param *strings: Anything 74 """ 75 76 print_message('DEBUG: %s' % (" - ".join(str(type(item)) for item in strings))) 77 78 def print_dir(*strings): 79 """ 80 Print dir wrapper. 81 82 @type *strings: anything 83 @param *strings: Anything 84 """ 85 86 print_message('DEBUG: %s' % (" - ".join(str(dir(item)) for item in strings))) 87 68 88 # Register them for global use 69 89 __builtin__.print_m = print_message … … 71 91 __builtin__.print_w = print_warning 72 92 __builtin__.print_d = print_debug 93 __builtin__.print_t = print_type 94 __builtin__.print_dir = print_dir 73 95 74 96 class BaseMessage: -
trunk/server.py
r277 r278 118 118 119 119 try: 120 if hasattr(self, 'server'): 121 self.server.startListening() 122 else: 123 self.server = reactor.listenTCP(port, self.site) 120 # We need to create a new instance because of server port changes, don't use hasattr() 121 # Returns a 'twisted.internet.tcp.Port' 122 self.server = reactor.listenTCP(port, self.site) 124 123 except twisted.internet.error.CannotListenError, e: 125 124 raise error.ItakaServerCannotListenError, e … … 149 148 Add a twisted.log observer 150 149 150 See: http://twistedmatrix.com/projects/core/documentation/howto/logging.html 151 151 @type observer: method 152 152 @param observer: A method to send the logs to … … 481 481 import pynotify 482 482 # 48x48 image by default looks bad in Ubuntu 483 uri = "file://" + (os.path.join(self.itaka_globals.image_dir, "itaka -take.png"))484 483 uri = "file://" + (os.path.join(self.itaka_globals.image_dir, "itaka512x512-take.png")) 484 485 485 n = pynotify.Notification(_('Screenshot taken'), _('%s captured the screen' % (self.ip)), uri) 486 486 -
trunk/uigtk.py
r277 r278 93 93 A log observer for our Twisted server 94 94 95 Interestingly it carries a time timestamp. 96 datetime.datetime.fromtimestamp(args['time']).strftime("%b %d %H:%M:%S") 97 95 98 @type args: dict 96 99 @param args: dict {'key': [str(message)]} 97 100 """ 98 101 99 102 # Handle twisted errors 100 103 # 'isError': 1, 'failure': <twisted.python.failure.Failure <type 'exceptions.AttributeError'>> … … 116 119 @param icon: The first argument is a string of either 'stock' or 'pixbuf', and the second is a string of gtk.STOCK_ICON or a gtk.gdk.pixbuf object (without the 'gtk.' prefix) 117 120 """ 118 121 122 if self.configuration['log']['logtimeformat']: 123 message = "%s %s" % (datetime.datetime.now().strftime(self.configuration['log']['logtimeformat']), message) 124 119 125 self.console.message(message) 120 126 self._write_gui_log(message, None, icon, False) … … 134 140 """ 135 141 142 if self.configuration['log']['logtimeformat']: 143 message = "%s %s" % (datetime.datetime.now().strftime(self.configuration['log']['logtimeformat']), message) 144 detailed_message = "%s %s" % (datetime.datetime.now().strftime(self.configuration['log']['logtimeformat']), detailed_message) 145 136 146 self.console.message(detailed_message) 137 147 self._write_gui_log(message, detailed_message, icon, False, False) … … 153 163 self.simple_message = message[0] 154 164 self.detailed_message = message[1] 165 166 if self.configuration['log']['logtimeformat']: 167 self.simple_message = "%s %s" % (datetime.datetime.now().strftime(self.configuration['log']['logtimeformat']), self.simple_message) 168 self.detailed_message = "%s %s" % (datetime.datetime.now().strftime(self.configuration['log']['logtimeformat']), self.detailed_message) 155 169 156 170 self.console.failure(caller, self.detailed_message, failure_type) … … 728 742 # Build a configuration dictionary to send to the configuration engine's 729 743 # save method. Redundant values must be included for the comparison 730 self.configuration dict = {744 self.configuration_dict = { 731 745 'html': 732 746 {'html': '<img src="screenshot" alt="If you are seeing this message it means there was an error in Itaka or you are using a text-only browser.">', … … 741 755 'scalepercent': self.scale_value[0]}, 742 756 757 'log': 758 {'logtimeformat': '[%d/%b/%Y %H:%M:%S]', 759 'logfile': '~/.itaka/access.log'}, 760 743 761 'server': 744 762 {'username': self.entry_preferences_user.get_text(), … … 767 785 768 786 # Check if the configuration changed 769 if (self.configuration dict != self.current_configuration):787 if (self.configuration_dict != self.current_configuration): 770 788 771 789 # Update the needed keys 772 790 try: 773 # self.config_instance.save(self.configuration dict)774 for section in self.configuration dict:775 [self.config_instance.update(section, key, value) for key, value in self.configuration dict[section].iteritems() if key not in self.current_configuration[section] or self.current_configuration[section][key] != value]791 # self.config_instance.save(self.configuration_dict) 792 for section in self.configuration_dict: 793 [self.config_instance.update(section, key, value) for key, value in self.configuration_dict[section].iteritems() if key not in self.current_configuration[section] or self.current_configuration[section][key] != value] 776 794 except: 777 795 self.log.failure(('Gui', '_save_preferences'), _('Could not save preferences'), 'ERROR') … … 1192 1210 if not self.expander.get_property("sensitive"): 1193 1211 self.expander.set_sensitive(True) 1212 self.expander.set_expanded(True) 1213 1194 1214 1195 1215 def stop_server(self, widget=None, foreign=False): … … 1254 1274 del self.status_icon 1255 1275 1256 self.log.verbose_message(_('Itaka Shutting down'), _('Received SIGINT, shutting down'), ['stock', 'STOCK_DISCONNECT'])1257 1258 1276 self.console.message(_('Itaka shutting down')) 1259 1277
Note: See TracChangeset
for help on using the changeset viewer.

