home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 January / maximum-cd-2011-01.iso / DiscContents / calibre-0.7.26.msi / file_1196 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-10-31  |  2.7 KB  |  64 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.png')
  17.     HELP = _('Debug the conversion process.')
  18.     COMMIT_NAME = 'debug'
  19.     
  20.     def __init__(self, parent, get_option, get_help, db = None, book_id = None):
  21.         Widget.__init__(self, parent, [
  22.             'debug_pipeline'])
  23.         self.db = db
  24.         self.book_id = book_id
  25.         self.initialize_options(get_option, get_help, db, book_id)
  26.         self.connect(self.button_debug_dir, SIGNAL('clicked()'), self.set_debug_dir)
  27.         self.connect(self.button_clear, SIGNAL('clicked()'), self.clear_debug_dir)
  28.  
  29.     
  30.     def clear_debug_dir(self):
  31.         self.opt_debug_pipeline.setText('')
  32.  
  33.     
  34.     def set_debug_dir(self):
  35.         x = choose_dir(self, 'conversion debug dir', _('Choose debug folder'))
  36.         if x:
  37.             self.opt_debug_pipeline.setText(x)
  38.         
  39.  
  40.     
  41.     def pre_commit_check(self):
  42.         
  43.         try:
  44.             x = unicode(self.opt_debug_pipeline.text()).strip()
  45.             if not x:
  46.                 return True
  47.             x = os.path.abspath(x)
  48.             if x:
  49.                 if not os.path.exists(x):
  50.                     os.makedirs(x)
  51.                 
  52.                 test = os.path.join(x, 'test')
  53.                 open(test, 'wb').close()
  54.                 os.remove(test)
  55.         except:
  56.             import traceback
  57.             det_msg = traceback.format_exc()
  58.             error_dialog(self, _('Invalid debug directory'), _('Failed to create debug directory') + ': ' + unicode(self.opt_debug_pipeline.text()), det_msg = det_msg, show = True)
  59.             return False
  60.  
  61.         return True
  62.  
  63.  
  64.