From 2a873594395ac9ebd4391a3db2eb1d1b49084217 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 28 Aug 2008 16:27:14 -0700 Subject: [PATCH] IGN:... --- src/calibre/constants.py | 2 +- src/calibre/ebooks/lrf/comic/convert_from.py | 4 +--- src/calibre/utils/PythonMagickWand.py | 4 ++-- src/calibre/utils/config.py | 24 ++++++++++++++------ upload.py | 6 +++++ 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/calibre/constants.py b/src/calibre/constants.py index f9a2380b41..8d2951fb26 100644 --- a/src/calibre/constants.py +++ b/src/calibre/constants.py @@ -2,7 +2,7 @@ __license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' __docformat__ = 'restructuredtext en' __appname__ = 'calibre' -__version__ = '0.4.83' +__version__ = '0.4.84b1' __author__ = "Kovid Goyal " ''' Various run time constants. diff --git a/src/calibre/ebooks/lrf/comic/convert_from.py b/src/calibre/ebooks/lrf/comic/convert_from.py index 46e2611044..dc4b2d5f3b 100755 --- a/src/calibre/ebooks/lrf/comic/convert_from.py +++ b/src/calibre/ebooks/lrf/comic/convert_from.py @@ -108,12 +108,10 @@ class PageProcessor(list): DestroyMagickWand(thumb) self.pages = [img] - if self.num == 2: - raise Exception('asd') if width > height: if self.opts.landscape: self.rotate = True - else: + else: split1, split2 = map(CloneMagickWand, (img, img)) if split1 < 0 or split2 < 0: raise RuntimeError('Cannot create wand.') diff --git a/src/calibre/utils/PythonMagickWand.py b/src/calibre/utils/PythonMagickWand.py index 301557c369..3c83ab4680 100644 --- a/src/calibre/utils/PythonMagickWand.py +++ b/src/calibre/utils/PythonMagickWand.py @@ -80,9 +80,9 @@ elif iswindows: if isfrozen else 'CORE_RL_wand_' else: _lib = util.find_library('MagickWand') + if _lib is None: + _lib = util.find_library('Wand') - - _magick = _magick_error = None try: _magick = ctypes.CDLL(_lib) diff --git a/src/calibre/utils/config.py b/src/calibre/utils/config.py index ab15cc6ce5..5ec24947dc 100644 --- a/src/calibre/utils/config.py +++ b/src/calibre/utils/config.py @@ -29,8 +29,10 @@ else: bdir = os.path.abspath(os.path.expanduser(os.environ.get('XDG_CONFIG_HOME', '~/.config'))) config_dir = os.path.join(bdir, 'calibre') -if not os.path.exists(config_dir): - os.makedirs(config_dir, mode=448) # 0700 == 448 +def make_config_dir(): + if not os.path.exists(config_dir): + os.makedirs(config_dir, mode=448) # 0700 == 448 + class CustomHelpFormatter(IndentedHelpFormatter): @@ -46,7 +48,7 @@ class CustomHelpFormatter(IndentedHelpFormatter): opts = self.option_strings[option] opt_width = self.help_position - self.current_indent - 2 if len(opts) > opt_width: - opts = "%*s%s\n" % (self.current_indent, "", + opts = "%*s%s\n" % (self.current_indent, "", terminal_controller.GREEN+opts+terminal_controller.NORMAL) indent_first = self.help_position else: # start help on same line as opts @@ -368,6 +370,8 @@ class Config(ConfigInterface): if not self.option_set.has_option(name): raise ValueError('The option %s is not defined.'%name) try: + if not os.path.exists(config_dir): + make_config_dir() with ExclusiveFile(self.config_file_path) as f: src = f.read() opts = self.option_set.parse_string(src) @@ -439,9 +443,11 @@ class DynamicConfig(dict): def __init__(self, name='dynamic'): self.name = name self.file_path = os.path.join(config_dir, name+'.pickle') - with ExclusiveFile(self.file_path) as f: - raw = f.read() - d = cPickle.loads(raw) if raw.strip() else {} + d = {} + if os.path.exists(self.file_path): + with ExclusiveFile(self.file_path) as f: + raw = f.read() + d = cPickle.loads(raw) if raw.strip() else {} dict.__init__(self, d) def __getitem__(self, key): @@ -459,6 +465,8 @@ class DynamicConfig(dict): def commit(self): if hasattr(self, 'file_path') and self.file_path: + if not os.path.exists(self.file_path): + make_config_dir() with ExclusiveFile(self.file_path) as f: raw = cPickle.dumps(self, -1) f.seek(0) @@ -487,6 +495,8 @@ def _prefs(): prefs = ConfigProxy(_prefs()) def migrate(): + if hasattr(os, 'geteuid') and os.geteuid() == 0: + return p = prefs if p.get('migrated'): return @@ -573,4 +583,4 @@ if __name__ == '__main__': opts = c.parse() for i in ('one', 'two', 'three', 'four'): print i, repr(getattr(opts, i)) - \ No newline at end of file + diff --git a/upload.py b/upload.py index e528c6f257..b4e74f161f 100644 --- a/upload.py +++ b/upload.py @@ -238,6 +238,12 @@ def stage_three(): check_call('''rm -rf dist/* build/*''') check_call('''ssh divok bzr update /var/www/calibre.kovidgoyal.net/calibre/''') +def betas(): + subprocess.check_call('rm -f dist/*', shell=True) + build_installers() + check_call('ssh divok rm -f /var/www/calibre.kovidgoyal.net/htdocs/downloads/betas/*') + check_call('scp dist/* divok:/var/www/calibre.kovidgoyal.net/htdocs/downloads/betas/') + def main(args=sys.argv): print 'Starting stage one...' stage_one()