~ubuntu-branches/ubuntu/karmic/calibre/karmic

« back to all changes in this revision

Viewing changes to upload.py

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-30 12:49:41 UTC
  • mfrom: (1.3.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090730124941-qjdsmri25zt8zocn
Tags: 0.6.3+dfsg-0ubuntu1
* New upstream release. Please see http://calibre.kovidgoyal.net/new_in_6/
  for the list of new features and changes.
* remove_postinstall.patch: Update for new version.
* build_debug.patch: Does not apply any more, disable for now. Might not be
  necessary any more.
* debian/copyright: Fix reference to versionless GPL.
* debian/rules: Drop obsolete dh_desktop call.
* debian/rules: Add workaround for weird Python 2.6 setuptools behaviour of
  putting compiled .so files into src/calibre/plugins/calibre/plugins
  instead of src/calibre/plugins.
* debian/rules: Drop hal fdi moving, new upstream version does not use hal
  any more. Drop hal dependency, too.
* debian/rules: Install udev rules into /lib/udev/rules.d.
* Add debian/calibre.preinst: Remove unmodified
  /etc/udev/rules.d/95-calibre.rules on upgrade.
* debian/control: Bump Python dependencies to 2.6, since upstream needs
  it now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
PREFIX = "/var/www/calibre.kovidgoyal.net"
19
19
DOWNLOADS = PREFIX+"/htdocs/downloads"
 
20
BETAS = DOWNLOADS +'/betas'
20
21
DOCS = PREFIX+"/htdocs/apidocs"
21
22
USER_MANUAL = PREFIX+'/htdocs/user_manual'
22
23
HTML2LRF = "src/calibre/ebooks/lrf/html/demo"
43
44
 
44
45
def newer(targets, sources):
45
46
    '''
46
 
    Return True is sources is newer that targets or if targets
 
47
    Return True if sources is newer that targets or if targets
47
48
    does not exist.
48
49
    '''
49
50
    for f in targets:
139
140
    RESOURCES = dict(
140
141
        opf_template    = 'ebooks/metadata/opf.xml',
141
142
        ncx_template    = 'ebooks/metadata/ncx.xml',
142
 
        fb2_xsl         = 'ebooks/lrf/fb2/fb2.xsl',
 
143
        fb2_xsl         = 'ebooks/fb2/fb2.xsl',
143
144
        metadata_sqlite = 'library/metadata_sqlite.sql',
144
145
        jquery          = 'gui2/viewer/jquery.js',
145
146
        jquery_scrollTo = 'gui2/viewer/jquery_scrollTo.js',
167
168
        sdir = os.path.join('src', 'calibre', 'library', 'static')
168
169
        resources, max = {}, 0
169
170
        for f in os.listdir(sdir):
170
 
            resources[f] = open(os.path.join(sdir, f), 'rb').read()
 
171
            resources[f] = self.get(os.path.join(sdir, f))
171
172
            mtime = os.stat(os.path.join(sdir, f)).st_mtime
172
173
            max = mtime if mtime > max else max
173
174
        return resources, max
177
178
        resources, max = {}, 0
178
179
        for f in os.listdir(sdir):
179
180
            if f.endswith('.py') and f != '__init__.py':
180
 
                resources[f.replace('.py', '')] = open(os.path.join(sdir, f), 'rb').read()
 
181
                resources[f.replace('.py', '')] = self.get(os.path.join(sdir, f))
181
182
                mtime = os.stat(os.path.join(sdir, f)).st_mtime
182
183
                max = mtime if mtime > max else max
183
184
        return resources, max
184
185
 
 
186
    def get_hyphenate(self):
 
187
        sdir = os.path.join('src', 'calibre', 'gui2', 'viewer', 'hyphenate')
 
188
        resources, max = {}, 0
 
189
        languages = set([])
 
190
        for f in glob.glob(os.path.join(sdir, 'patterns', '*.js')) + \
 
191
                [os.path.join(sdir, 'Hyphenator.js')]:
 
192
                f = os.path.abspath(f)
 
193
                b = os.path.basename(f)
 
194
                resources[b] = self.get(f)
 
195
                if b != 'Hyphenator.js':
 
196
                    languages.add(b.split('.')[0])
 
197
                mtime = os.stat(f).st_mtime
 
198
                max = mtime if mtime > max else max
 
199
        resources['languages'] = ','.join(languages)
 
200
        return resources, max
 
201
 
185
202
    def run(self):
186
203
        data, dest, RESOURCES = {}, self.DEST, self.RESOURCES
187
204
        for key in RESOURCES:
192
209
        RESOURCES.update(translations)
193
210
        static, smax = self.get_static_resources()
194
211
        recipes, rmax = self.get_recipes()
195
 
        amax = max(rmax, smax)
 
212
        hyphenate, hmax = self.get_hyphenate()
 
213
        amax = max(rmax, smax, hmax, os.stat(__file__).st_mtime)
196
214
        if newer([dest], RESOURCES.values()) or os.stat(dest).st_mtime < amax:
197
215
            print 'Compiling resources...'
198
216
            with open(dest, 'wb') as f:
199
217
                for key in RESOURCES:
200
 
                    data = open(RESOURCES[key], 'rb').read()
 
218
                    data = self.get(RESOURCES[key])
201
219
                    f.write(key + ' = ' + repr(data)+'\n\n')
202
220
                f.write('server_resources = %s\n\n'%repr(static))
203
221
                f.write('recipes = %s\n\n'%repr(recipes))
 
222
                f.write('hyphenate = %s\n\n'%repr(hyphenate))
204
223
                f.write('build_time = "%s"\n\n'%time.strftime('%d %m %Y %H%M%S'))
205
224
        else:
206
225
            print 'Resources are up to date'
207
226
 
 
227
    def get(self, path):
 
228
        data = open(path, 'rb').read()
 
229
        if path.endswith('.js') and not path.endswith('date.js'):
 
230
            data = self.js_minify(data)
 
231
        return data
 
232
 
 
233
    def js_minify(self, data):
 
234
        from jsmin import jsmin
 
235
        return jsmin(data)
 
236
 
208
237
    @classmethod
209
238
    def clean(cls):
210
239
        path = cls.DEST
312
341
                dat = dat.replace('import images_rc', 'from calibre.gui2 import images_rc')
313
342
                dat = dat.replace('from library import', 'from calibre.gui2.library import')
314
343
                dat = dat.replace('from widgets import', 'from calibre.gui2.widgets import')
 
344
                dat = dat.replace('from convert.xpath_wizard import',
 
345
                    'from calibre.gui2.convert.xpath_wizard import')
315
346
                dat = re.compile(r'QtGui.QApplication.translate\(.+?,\s+"(.+?)(?<!\\)",.+?\)', re.DOTALL).sub(r'_("\1")', dat)
316
347
 
317
348
                # Workaround bug in Qt 4.4 on Windows
427
458
 
428
459
    def run(self):
429
460
        check_call(
430
 
           '''html2lrf --title='Demonstration of html2lrf' --author='Kovid Goyal' '''
431
 
           '''--header --output=/tmp/html2lrf.lrf %s/demo.html '''
 
461
           '''ebook-convert %s/demo.html /tmp/html2lrf.lrf '''
 
462
           '''--title='Demonstration of html2lrf' --authors='Kovid Goyal' '''
 
463
           '''--header '''
432
464
           '''--serif-family "/usr/share/fonts/corefonts, Times New Roman" '''
433
465
           '''--mono-family  "/usr/share/fonts/corefonts, Andale Mono" '''
434
466
           ''''''%(HTML2LRF,), shell=True)
439
471
 
440
472
        check_call('scp /tmp/html-demo.zip divok:%s/'%(DOWNLOADS,), shell=True)
441
473
 
442
 
        check_call(
443
 
           '''txt2lrf -t 'Demonstration of txt2lrf' -a 'Kovid Goyal' '''
444
 
           '''--header -o /tmp/txt2lrf.lrf %s/demo.txt'''%(TXT2LRF,), shell=True)
445
 
 
446
 
        check_call('cd src/calibre/ebooks/lrf/txt/demo/ && '
447
 
                   'zip -j /tmp/txt-demo.zip * /tmp/txt2lrf.lrf', shell=True)
448
 
 
449
 
        check_call('''scp /tmp/txt-demo.zip divok:%s/'''%(DOWNLOADS,), shell=True)
450
 
 
451
474
 
452
475
def installer_name(ext):
453
476
    if ext in ('exe', 'dmg'):
544
567
 
545
568
class build_osx(VMInstaller):
546
569
    description = 'Build OS X app bundle'
547
 
    VM = '/vmware/Mac OSX/Mac OSX.vmx'
 
570
    VM = '/mnt/backup/calibre_os_x/Mac OSX.vmx'
548
571
    if not os.path.exists(VM):
549
572
        VM = '/home/kovid/calibre_os_x/Mac OSX.vmx'
550
573
 
703
726
                ('upload_demo', None),
704
727
                ]
705
728
 
 
729
class betas(OptionlessCommand):
 
730
    description = 'Build an upload beta builds to the servers'
 
731
 
 
732
    sub_commands = [ ('update', None), ('stage2', None) ]
 
733
 
 
734
    def run(self):
 
735
        OptionlessCommand.run(self)
 
736
        check_call('scp dist/* divok:'+BETAS, shell=True)
 
737
 
706
738
class upload(OptionlessCommand):
707
739
    description = 'Build and upload calibre to the servers'
708
740
 
721
753
        class ChangelogFormatter(blog.LogFormatter):
722
754
            supports_tags = True
723
755
            supports_merge_revisions = False
 
756
            _show_advice = False
724
757
 
725
758
            def __init__(self, num_of_versions=20):
726
759
                from calibre.utils.rss_gen import RSS2
745
778
                        mkup = '<div><ul>%s</ul></div>'
746
779
                        self.current_entry.description = mkup%(''.join(
747
780
                                    self.current_entry.description))
748
 
 
 
781
                        if match.group(1) == '0.5.14':
 
782
                            self.current_entry.description = \
 
783
                            '''<div>See <a href="http://calibre.kovidgoyal.net/new_in_6">New in
 
784
                            6</a></div>'''
749
785
                        self.rss.items.append(self.current_entry)
750
786
                    timestamp = r.rev.timezone + r.rev.timestamp
751
787
                    self.current_entry = RSSItem(