mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fully automate building of windows installer
This commit is contained in:
parent
b82044dfa4
commit
8a9110740d
@ -8,5 +8,6 @@
|
|||||||
<path>/libprs500/devices</path>
|
<path>/libprs500/devices</path>
|
||||||
<path>/libprs500/libprs500.devices.prs500</path>
|
<path>/libprs500/libprs500.devices.prs500</path>
|
||||||
<path>/libprs500/prs500</path>
|
<path>/libprs500/prs500</path>
|
||||||
|
<path>/libprs500/gui2</path>
|
||||||
</pydev_pathproperty>
|
</pydev_pathproperty>
|
||||||
</pydev_project>
|
</pydev_project>
|
||||||
|
2
setup.py
2
setup.py
@ -60,7 +60,7 @@ if sys.argv[1] == 'py2exe':
|
|||||||
os.makedirs(dir)
|
os.makedirs(dir)
|
||||||
shutil.copy(file, dir)
|
shutil.copy(file, dir)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print >>sys.stderr, 'Must be in Windows to run py2exe'
|
print >>sys.stderr, 'Failed to import py2exe'
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
installer = \
|
installer = \
|
||||||
r'''
|
r'''
|
||||||
|
@ -618,6 +618,9 @@ class LibraryDatabase(object):
|
|||||||
def rows(self):
|
def rows(self):
|
||||||
return len(self.data) if self.data else 0
|
return len(self.data) if self.data else 0
|
||||||
|
|
||||||
|
def id(self, index):
|
||||||
|
return self.data[index][0]
|
||||||
|
|
||||||
def title(self, index):
|
def title(self, index):
|
||||||
return self.data[index][1]
|
return self.data[index][1]
|
||||||
|
|
||||||
@ -635,7 +638,65 @@ class LibraryDatabase(object):
|
|||||||
|
|
||||||
def max_size(self, index):
|
def max_size(self, index):
|
||||||
return self.data[index][6]
|
return self.data[index][6]
|
||||||
|
|
||||||
|
def set(self, row, column, val):
|
||||||
|
''' Convenience method for setting the title, authors, publisher or rating '''
|
||||||
|
id = self.data[row][0]
|
||||||
|
cols = {'title' : 1, 'authors': 2, 'publisher': 3, 'rating':4}
|
||||||
|
col = cols[column]
|
||||||
|
self.data[row][col] = val
|
||||||
|
for item in self.cache:
|
||||||
|
if item[0] == id:
|
||||||
|
item[col] = val
|
||||||
|
break
|
||||||
|
if column == 'authors':
|
||||||
|
val = val.split('&,')
|
||||||
|
self.set_authors(id, val)
|
||||||
|
elif column == 'title':
|
||||||
|
self.set_title(id, val)
|
||||||
|
elif column == 'publisher':
|
||||||
|
self.set_publisher(id, val)
|
||||||
|
elif column == 'rating':
|
||||||
|
self.set_rating(id, val)
|
||||||
|
print row, col, val
|
||||||
|
|
||||||
|
def set_authors(self, id, authors):
|
||||||
|
self.conn.execute('DELETE FROM books_authors_link WHERE book=?',(id,))
|
||||||
|
for a in authors:
|
||||||
|
if not a:
|
||||||
|
continue
|
||||||
|
author = conn.execute('SELECT id from authors WHERE name=?', (a,)).fetchone()
|
||||||
|
if author:
|
||||||
|
aid = author[0]
|
||||||
|
else:
|
||||||
|
aid = conn.execute('INSERT INTO authors(name) VALUES (?)', (a,)).lastrowid
|
||||||
|
conn.execute('INSERT INTO books_authors_link(book, author) VALUES (?,?)', (id, aid))
|
||||||
|
self.conn.commit()
|
||||||
|
|
||||||
|
def set_title(self, id, title):
|
||||||
|
if not title:
|
||||||
|
return
|
||||||
|
self.conn.execute('UPDATE books SET title=? WHERE id=?', (title, id))
|
||||||
|
self.conn.commit()
|
||||||
|
|
||||||
|
def set_publisher(self, id, publisher):
|
||||||
|
if not publisher:
|
||||||
|
return
|
||||||
|
self.conn.execute('DELETE FROM books_publishers_link WHERE book=?',(id,))
|
||||||
|
pub = conn.execute('SELECT id from publishers WHERE name=?', (publisher,)).fetchone()
|
||||||
|
if pub:
|
||||||
|
aid = pub[0]
|
||||||
|
else:
|
||||||
|
pub = conn.execute('INSERT INTO publishers(name) VALUES (?)', (publisher,)).lastrowid
|
||||||
|
conn.execute('INSERT INTO books_publishers_link(book, publisher) VALUES (?,?)', (id, aid))
|
||||||
|
self.conn.commit()
|
||||||
|
|
||||||
|
def set_rating(self, id, rating):
|
||||||
|
rating = int(rating)
|
||||||
|
self.conn.execute('DELETE FROM books_ratings_link WHERE book=?',(id,))
|
||||||
|
rat = conn.execute('SELECT id FROM ratings WHERE rating=?', (rating,)).fetchone()
|
||||||
|
rat = rat[0] if rat else conn.execute('INSERT INTO ratings(rating) VALUES (?)', (rating,)).lastrowid
|
||||||
|
conn.execute('INSERT INTO books_ratings_link(book, rating) VALUES (?,?)', (id, rat))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from IPython.Shell import IPShellEmbed
|
from IPython.Shell import IPShellEmbed
|
||||||
|
83
upload
83
upload
@ -1,28 +1,67 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/python
|
||||||
|
import sys, glob, os, subprocess
|
||||||
|
from pyvix.vix import *
|
||||||
|
|
||||||
# Script to upload libprs500 to pypi, the installer to libprs500.kovidgoyal.net and update the api documentation
|
files = glob.glob('dist/*.exe')
|
||||||
|
for file in files:
|
||||||
|
os.unlink(file)
|
||||||
|
|
||||||
PREFIX=/var/www/vhosts/kovidgoyal.net/subdomains/libprs500
|
|
||||||
DOWNLOADS=$PREFIX/httpdocs/downloads
|
|
||||||
DOCS=$PREFIX/httpdocs/apidocs
|
|
||||||
exe=`cd dist && ls -1 libprs500-*.exe | tail -n1 && cd ..`
|
|
||||||
HTML2LRF=src/libprs500/ebooks/lrf/html/demo
|
|
||||||
|
|
||||||
echo "<h2>The HTML</h2><pre>" > ${HTML2LRF}/demo_ext.html
|
h = Host(hostType=VIX_SERVICEPROVIDER_VMWARE_WORKSTATION)
|
||||||
cat ${HTML2LRF}/demo.html >> ${HTML2LRF}/demo_ext.html
|
vm = h.openVM('/mnt/extra/vmware/Windows Vista/Windows Vista.vmx')
|
||||||
echo '</pre>' >> ${HTML2LRF}/demo_ext.html
|
vm.powerOn()
|
||||||
html2lrf --title='Demonstration of html2lrf' --author='Kovid Goyal' --header --output=/tmp/html2lrf.lrf ${HTML2LRF}/demo.html
|
if not vm.waitForToolsInGuest():
|
||||||
scp /tmp/html2lrf.lrf castalia:$DOWNLOADS/
|
print >>sys.stderr, 'Windows is not booting up'
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
ssh castalia rm -f $DOWNLOADS/libprs500\*.exe
|
|
||||||
scp dist/$exe castalia:$DOWNLOADS/
|
|
||||||
ssh castalia chmod a+r $DOWNLOADS/\*
|
|
||||||
ssh castalia /root/bin/update-installer-link $exe
|
|
||||||
|
|
||||||
epydoc --config epydoc.conf
|
|
||||||
scp -r docs/html castalia:$DOCS/
|
|
||||||
epydoc -v --config epydoc-pdf.conf
|
|
||||||
scp docs/pdf/api.pdf castalia:$DOCS/
|
|
||||||
|
|
||||||
python setup.py register sdist bdist_egg upload
|
vm.loginInGuest('kovid', 'et tu brutus')
|
||||||
rm -rf dist/* build/*
|
vm.loginInGuest(VIX_CONSOLE_USER_NAME, '')
|
||||||
|
vm.runProgramInGuest('C:\\Users\kovid\Desktop\libprs500.bat', '')
|
||||||
|
vm.runProgramInGuest('C:\Windows\system32\shutdown.exe', '/s')
|
||||||
|
|
||||||
|
if not glob.glob('dist/*.exe'):
|
||||||
|
raise Exception('Windows build has failed')
|
||||||
|
|
||||||
|
|
||||||
|
PREFIX = "/var/www/vhosts/kovidgoyal.net/subdomains/libprs500"
|
||||||
|
DOWNLOADS = PREFIX+"/httpdocs/downloads"
|
||||||
|
DOCS = PREFIX+"/httpdocs/apidocs"
|
||||||
|
exe = os.path.basename(glob.glob('dist/*.exe')[0])
|
||||||
|
HTML2LRF = "src/libprs500/ebooks/lrf/html/demo"
|
||||||
|
|
||||||
|
f = open(os.path.join(HTML2LRF, 'demo_ext.html'), 'w')
|
||||||
|
f.write("<h2>The HTML</h2><pre>\n")
|
||||||
|
f.write(open(os.path.join(HTML2LRF, 'demo.html')).read())
|
||||||
|
f.write('\n</pre>')
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
def check_call(cmd):
|
||||||
|
try:
|
||||||
|
retcode = subprocess.call(cmd, shell=True)
|
||||||
|
if retcode < 0:
|
||||||
|
print >>sys.stderr, cmd, "was terminated by signal", -retcode
|
||||||
|
elif retcode > 0:
|
||||||
|
print >>sys.stderr, cmd, 'failed with retrun code:', retcode
|
||||||
|
if retcode != 0:
|
||||||
|
sys.exit(1)
|
||||||
|
except OSError, e:
|
||||||
|
print >>sys.stderr, "Execution of", cmd, "failed:", e
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
check_call('''html2lrf --title='Demonstration of html2lrf' --author='Kovid Goyal' --header --output=/tmp/html2lrf.lrf %s/demo.html'''%(HTML2LRF,))
|
||||||
|
check_call('''scp /tmp/html2lrf.lrf castalia:%s/'''%(DOWNLOADS,))
|
||||||
|
check_call('''python setup.py register sdist bdist_egg upload''')
|
||||||
|
|
||||||
|
check_call('''ssh castalia rm -f %s/libprs500\*.exe'''%(DOWNLOADS,))
|
||||||
|
check_call('''scp dist/%s castalia:%s/'''%(exe, DOWNLOADS))
|
||||||
|
check_call('''ssh castalia chmod a+r %s/\*'''%(DOWNLOADS,))
|
||||||
|
check_call('''ssh castalia /root/bin/update-installer-link %s'''%(exe,))
|
||||||
|
|
||||||
|
check_call('''epydoc --config epydoc.conf''')
|
||||||
|
check_call('''scp -r docs/html castalia:%s/'''%(DOCS,))
|
||||||
|
check_call('''epydoc -v --config epydoc-pdf.conf''')
|
||||||
|
check_call('''scp docs/pdf/api.pdf castalia:%s/'''%(DOCS,))
|
||||||
|
|
||||||
|
check_call('''rm -rf dist/* build/*''')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user