From 2537df374ec929222f33c67524d65eb0da3dcb96 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 24 Jan 2008 20:07:57 +0000 Subject: [PATCH] version 0.4.34 --- src/libprs500/linux.py | 85 +++++++++++++++++++++++------------------- upload.py | 55 ++++++--------------------- 2 files changed, 59 insertions(+), 81 deletions(-) diff --git a/src/libprs500/linux.py b/src/libprs500/linux.py index 3873e1700e..4c955bb9cb 100644 --- a/src/libprs500/linux.py +++ b/src/libprs500/linux.py @@ -231,13 +231,10 @@ def post_install(): if os.geteuid() != 0: print >> sys.stderr, 'You must be root to run this command.' sys.exit(1) - + setup_udev_rules() setup_completion() - try: - setup_desktop_integration() - except: - print >>sys.stderr, 'You do not have the Portland Desktop Utilities installed, skipping installation of desktop integration' + setup_desktop_integration() try: from PyQt4 import Qt @@ -288,40 +285,52 @@ MIME = '''\ ''' def setup_desktop_integration(): - from PyQt4.QtGui import QApplication, QPixmap - from PyQt4.QtCore import Qt - from libprs500.gui2 import images_rc - from tempfile import mkdtemp - - print 'Setting up desktop integration...' - - app = QApplication([]) - svg = QPixmap(':/images/mimetypes/lrf.svg').scaled(128, 128, Qt.KeepAspectRatio, Qt.SmoothTransformation) - gui = QPixmap(':library').scaled(128, 128, Qt.KeepAspectRatio, Qt.SmoothTransformation) - viewer = QPixmap(':/images/viewer.svg').scaled(128, 128, Qt.KeepAspectRatio, Qt.SmoothTransformation) - tdir = mkdtemp() try: - os.chdir(tdir) - svg.save(os.path.join(tdir, 'libprs500-lrf.png'), 'PNG') - gui.save(os.path.join(tdir, 'libprs500-gui.png'), 'PNG') - viewer.save(os.path.join(tdir, 'libprs500-viewer.png'), 'PNG') - check_call('xdg-icon-resource install --context mimetypes --size 128 libprs500-lrf.png application-lrf', shell=True) - check_call('xdg-icon-resource install --context mimetypes --size 128 libprs500-lrf.png text-lrs', shell=True) - check_call('xdg-icon-resource install --size 128 libprs500-gui.png libprs500-gui', shell=True) - check_call('xdg-icon-resource install --size 128 libprs500-viewer.png libprs500-viewer', shell=True) - f = open('libprs500-lrfviewer.desktop', 'wb') - f.write(VIEWER) - f.close() - f = open('libprs500-gui.desktop', 'wb') - f.write(GUI) - f.close() - check_call('xdg-desktop-menu install ./libprs500-gui.desktop ./libprs500-lrfviewer.desktop', shell=True) - f = open('libprs500-mimetypes', 'wb') - f.write(MIME) - f.close() - check_call('xdg-mime install libprs500-mimetypes', shell=True) - finally: - shutil.rmtree(tdir) + from PyQt4.QtCore import QFile + from libprs500.gui2 import images_rc # Load images + from tempfile import mkdtemp + + print 'Setting up desktop integration...' + + + tdir = mkdtemp() + rsvg = 'rsvg --dpi-x 600 --dpi-y 600 -w 128 -h 128 -f png ' + cwd = os.getcwdu() + try: + os.chdir(tdir) + if QFile(':/images/mimetypes/lrf.svg').copy(os.path.join(tdir, 'libprs500-lrf.svg')): + check_call(rsvg + 'libprs500-lrf.svg libprs500-lrf.png', shell=True) + check_call('xdg-icon-resource install --context mimetypes --size 128 libprs500-lrf.png application-lrf', shell=True) + check_call('xdg-icon-resource install --context mimetypes --size 128 libprs500-lrf.png text-lrs', shell=True) + else: + raise Exception('Could not create LRF mimetype icon') + if QFile(':library').copy(os.path.join(tdir, 'libprs500-gui.png')): + check_call('xdg-icon-resource install --size 128 libprs500-gui.png libprs500-gui', shell=True) + else: + raise Exception('Could not creaet GUI icon') + if QFile(':/images/viewer.svg').copy(os.path.join(tdir, 'libprs500-viewer.svg')): + check_call(rsvg + 'libprs500-viewer.svg libprs500-viewer.png', shell=True) + check_call('xdg-icon-resource install --size 128 libprs500-viewer.png libprs500-viewer', shell=True) + else: + raise Exception('Could not creaet viewer icon') + + f = open('libprs500-lrfviewer.desktop', 'wb') + f.write(VIEWER) + f.close() + f = open('libprs500-gui.desktop', 'wb') + f.write(GUI) + f.close() + check_call('xdg-desktop-menu install ./libprs500-gui.desktop ./libprs500-lrfviewer.desktop', shell=True) + f = open('libprs500-mimetypes', 'wb') + f.write(MIME) + f.close() + check_call('xdg-mime install libprs500-mimetypes', shell=True) + finally: + os.chdir(cwd) + shutil.rmtree(tdir) + except Exception, err: + print >>sys.stderr, 'Could not setup desktop integration. Error:' + print err if __name__ == '__main__': diff --git a/upload.py b/upload.py index 1161ee6194..5c140c6d7c 100644 --- a/upload.py +++ b/upload.py @@ -13,53 +13,22 @@ TXT2LRF = "src/libprs500/ebooks/lrf/txt/demo" check_call = partial(_check_call, shell=True) h = Host(hostType=VIX_SERVICEPROVIDER_VMWARE_WORKSTATION) + def build_windows(): - files = glob.glob('dist/*.exe') - for file in files: - os.unlink(file) - - - - vm = h.openVM('/mnt/vista/Windows Vista/Windows Vista.vmx') - vm.powerOn() - if not vm.waitForToolsInGuest(): - print >>sys.stderr, 'Windows is not booting up' - sys.exit(1) - - - - vm.loginInGuest('kovid', 'et tu brutus') - vm.loginInGuest(VIX_CONSOLE_USER_NAME, '') - vm.runProgramInGuest('C:\\Users\kovid\Desktop\libprs500.bat', '') - if not glob.glob('dist/*.exe'): - raise Exception('Windows build has failed') - vm.runProgramInGuest('C:\Windows\system32\shutdown.exe', '/s') - return os.path.basename(glob.glob('dist/*.exe')[-1]) + from libprs500 import __version__ + installer = 'dist/libprs500-%s.exe'%__version__ + if not os.path.exists(installer): + raise Exception('You must build the windows installer before running this script') + + return os.path.basename(installer) def build_osx(): - files = glob.glob('dist/*.dmg') - for file in files: - os.unlink(file) - if os.path.exists('dist/dmgdone'): - os.unlink('dist/dmgdone') - - vm = h.openVM('/mnt/osx/Mac OSX/Mac OSX.vmx') - vm.powerOn() - c = 25 * 60 - print 'Waiting (minutes):', - while c > 0 and not os.path.exists('dist/dmgdone'): - time.sleep(10) - c -= 10 - if c%60==0: - print c/60, ',', - sys.stdout.flush() - print + from libprs500 import __version__ + installer = 'dist/libprs500-%s.dmg'%__version__ + if not os.path.exists(installer): + raise Exception('You must build the OSX installer before running this script') - if not os.path.exists('dist/dmgdone'): - raise Exception('OSX build has failed') - vm.powerOff() - return os.path.basename(glob.glob('dist/*.dmg')[-1]) - + return os.path.basename(installer) def upload_demo():