home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1170 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  2.7 KB  |  63 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. from __future__ import with_statement
  5. __license__ = 'GPL v3'
  6. __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
  7. __docformat__ = 'restructuredtext en'
  8. import os
  9. from PyQt4.Qt import SIGNAL
  10. from calibre.gui2.convert.debug_ui import Ui_Form
  11. from calibre.gui2.convert import Widget
  12. from calibre.gui2 import error_dialog, choose_dir
  13.  
  14. class DebugWidget(Widget, Ui_Form):
  15.     TITLE = _('Debug')
  16.     ICON = I('debug.svg')
  17.     HELP = _('Debug the conversion process.')
  18.     
  19.     def __init__(self, parent, get_option, get_help, db = None, book_id = None):
  20.         Widget.__init__(self, parent, 'debug', [
  21.             'debug_pipeline'])
  22.         self.db = db
  23.         self.book_id = book_id
  24.         self.initialize_options(get_option, get_help, db, book_id)
  25.         self.connect(self.button_debug_dir, SIGNAL('clicked()'), self.set_debug_dir)
  26.         self.connect(self.button_clear, SIGNAL('clicked()'), self.clear_debug_dir)
  27.  
  28.     
  29.     def clear_debug_dir(self):
  30.         self.opt_debug_pipeline.setText('')
  31.  
  32.     
  33.     def set_debug_dir(self):
  34.         x = choose_dir(self, 'conversion debug dir', _('Choose debug folder'))
  35.         if x:
  36.             self.opt_debug_pipeline.setText(x)
  37.         
  38.  
  39.     
  40.     def pre_commit_check(self):
  41.         
  42.         try:
  43.             x = unicode(self.opt_debug_pipeline.text()).strip()
  44.             if not x:
  45.                 return True
  46.             x = os.path.abspath(x)
  47.             if x:
  48.                 if not os.path.exists(x):
  49.                     os.makedirs(x)
  50.                 
  51.                 test = os.path.join(x, 'test')
  52.                 open(test, 'wb').close()
  53.                 os.remove(test)
  54.         except:
  55.             import traceback
  56.             det_msg = traceback.format_exc()
  57.             error_dialog(self, _('Invalid debug directory'), _('Failed to create debug directory') + ': ' + unicode(self.opt_debug_pipeline.text()), det_msg = det_msg, show = True)
  58.             return False
  59.  
  60.         return True
  61.  
  62.  
  63.