This commit is contained in:
Kovid Goyal 2008-08-28 16:27:14 -07:00
parent a4d6a595c2
commit 2a87359439
5 changed files with 27 additions and 13 deletions

View File

@ -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 <kovid@kovidgoyal.net>"
'''
Various run time constants.

View File

@ -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.')

View File

@ -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)

View File

@ -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))

View File

@ -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()