diff --git a/contrib/windows-install/HOW_TO.txt b/contrib/windows-install/HOW_TO.txt new file mode 100644 index 00000000..c37b0e30 --- /dev/null +++ b/contrib/windows-install/HOW_TO.txt @@ -0,0 +1,5 @@ +1. Replace weboob egg file + +2. update settings.cmd + +3. run create-exe-setup-weboob.bat \ No newline at end of file diff --git a/contrib/windows-install/ICON/weboobtxt.ico b/contrib/windows-install/ICON/weboobtxt.ico new file mode 100644 index 00000000..134600fa Binary files /dev/null and b/contrib/windows-install/ICON/weboobtxt.ico differ diff --git a/contrib/windows-install/convertPNG2ICO.py b/contrib/windows-install/convertPNG2ICO.py new file mode 100644 index 00000000..5b23e6d9 --- /dev/null +++ b/contrib/windows-install/convertPNG2ICO.py @@ -0,0 +1,109 @@ +#!C:\Python27\python.exe +# -*- coding: utf-8 -*- +# +# windows icon file(.ico) and cursor file(.cur) generator/writer from RGB(a) array +# +# NOTICE: one image per file *only*, 16x16 or 32x32 or 48x48 or 64x64 *only* +# Support 24 bit & 32 bit(RGB + alpha) +# +# Copyright 2009 ( http://creativecommons.org/licenses/by-nc-sa/2.5/cn/ ) +# +# About Author +# Blog( http://2maomao.com/blog/ ) +# Website( http://fayaa.com/tool/favicon/ ) +# Contact me via email +# +# References: +# [1] http://en.wikipedia.org/wiki/Ico_Format +# [2] http://en.wikipedia.org/wiki/Windows_and_OS/2_bitmap +# [3] http://support.microsoft.com/kb/83034 +# [4] http://msdn.microsoft.com/en-us/library/ms997538(loband).aspx +# [5] http://www.martinreddy.net/gfx/2d/BMP.txt +# [6] http://code.google.com/p/casadebender/source/browse/python/PIL/Win32IconImagePlugin.py +# [7] http://www.osphp.com.cn/read.php/290.htm + +from PIL import Image +import sys +import os + + +# data: a size*size of (r,g,b,t) tuples, t for tansparency(if True) +# (r,g,b,a) if bpp is 32 +# size: could be 16 or 32 or 48 or 64, other value NOT supported +# bpp: bits per pixel, could *only* be 24 or 32! +# return: an "array" of BYTES which, if write to file, is a size*size ico file +def genico(data, size=16, bpp=24): + from array import array + a = array('B') + #header(ref1&5) + a.extend((0,0, 1,0, 1,0)) #reserved*2, icon,0, 1 image per-file,0 + #directory(ref1&5&7) + imglen = 40+size*(size*3 + (size+16)/32*32/8) #image-part length in bytes + #!hack! AND bits align to 32 bits per line + #!shit! MSDN says nothing about this + if bpp == 32: + imglen += size*size #1 more byte for alpha value of each pixel + a.extend((size,size, 0,0, 1,0, bpp,0)) #w,h, reserved*2, 1plane*2, bpp*2 + a.extend((imglen&0xff,imglen>>8,0,0, 22,0,0,0)) #bitmap-size*4,22B-offset*4 + #image BITMAPINFOHEADER(ref5) + a.extend((40,0,0,0)) #size of data(contains header)*4 + a.extend((size,0,0,0, size*2,0,0,0))#w*4, (h+h)*4 (!shit hack! XOR+AND) + a.extend((1,0, bpp,0, 0,0,0,0, 0,0,0,0)) #1 plane*2, 24 bits*2, no compress*4, rawBMPsize(no compress so 0)*4 + a.extend((0,1,0,0, 0,1,0,0)) #horizontal*4/vertical*4 resolution pixels/meter(WTF?) + a.extend((0,0,0,0, 0,0,0,0)) #colors fully used, all are important + #!no planes + #image content(ref1&5), XOR+AND bitmaps + AND = array('B') + vand = 0 + vcnt = 0 + #remember that bitmap format is reversed in y-axis + for x in range(size-1,-1,-1): + for y in range(0, size): + b,g,r,t_or_a = data[y*size+x] + a.extend((r,g,b)) + if bpp == 32: + a.append(t_or_a) + vcnt+=1 + vand<<=1 + if (bpp==24 and t_or_a) or (bpp==32 and t_or_a<128): + vand |= 1 + if vcnt==8: + AND.append(vand) + vcnt=0 + vand=0 + #!hack! AND bits align to 32 bits per line, !shit! MSDN says nothing about this + AND.extend([0] * ((32-size%32)%32/8)) + a.extend(AND) + return a + +# x,y indicate the hotspot position +# simply set the type/hotspot(x&y) after generates the icon +def gencur(data, size=16, bpp=24, x=0, y=0): + a = genico(data, size, bpp) + a[3], a[10], a[12] = 2, x, y + return a + +#C:\Python27\Lib\site-packages\weboob-0.g-py2.7.egg\share\icons\hicolor\64x64\apps + +if __name__ == "__main__": + if len(sys.argv) == 2: + png_file = sys.argv[1] + + f, e = os.path.splitext(png_file) + ico_file = f + ".ico" + + im = Image.open(r"%s" % png_file) + wh = 64 + + rgba = im.convert("RGBA") + + data = [] + for i in range(wh): + for j in range(wh): + data.append(rgba.getpixel((i,j))) + + + icoflow = genico(data, wh, 32) + _file = open(ico_file, "wb") + icoflow.tofile(_file) + _file.close() diff --git a/contrib/windows-install/create-exe-setup-weboob.bat b/contrib/windows-install/create-exe-setup-weboob.bat new file mode 100644 index 00000000..9cfe7949 --- /dev/null +++ b/contrib/windows-install/create-exe-setup-weboob.bat @@ -0,0 +1,3 @@ +@echo off +call settings.cmd +"Bat_To_Exe_Converter.exe" -bat "setup-weboob.bat" -save "setup-weboob-%WEBOOB_VERSION%.exe" -icon "ICON\weboobtxt.ico" -include "Bat_To_Exe_Converter.exe" -include "wget-1.11.4-1-setup.exe" -include "weboob-%WEBOOB_VERSION%-py2.7.egg" -include "convertPNG2ICO.py" -include "ez_setup.py" -include "settings.cmd" diff --git a/contrib/windows-install/ez_setup.py b/contrib/windows-install/ez_setup.py new file mode 100644 index 00000000..9d0a5940 --- /dev/null +++ b/contrib/windows-install/ez_setup.py @@ -0,0 +1,370 @@ +#!python +"""Bootstrap setuptools installation + +If you want to use setuptools in your package's setup.py, just include this +file in the same directory with it, and add this to the top of your setup.py:: + + from ez_setup import use_setuptools + use_setuptools() + +If you want to require a specific version of setuptools, set a download +mirror, or use an alternate download directory, you can do so by supplying +the appropriate options to ``use_setuptools()``. + +This file can also be run as a script to install or upgrade setuptools. +""" +import os +import shutil +import sys +import tempfile +import tarfile +import optparse +import subprocess +import platform + +from distutils import log + +try: + from site import USER_SITE +except ImportError: + USER_SITE = None + +DEFAULT_VERSION = "1.1.6" +DEFAULT_URL = "https://pypi.python.org/packages/source/s/setuptools/" + +def _python_cmd(*args): + args = (sys.executable,) + args + return subprocess.call(args) == 0 + +def _check_call_py24(cmd, *args, **kwargs): + res = subprocess.call(cmd, *args, **kwargs) + class CalledProcessError(Exception): + pass + if not res == 0: + msg = "Command '%s' return non-zero exit status %d" % (cmd, res) + raise CalledProcessError(msg) +vars(subprocess).setdefault('check_call', _check_call_py24) + +def _install(tarball, install_args=()): + # extracting the tarball + tmpdir = tempfile.mkdtemp() + log.warn('Extracting in %s', tmpdir) + old_wd = os.getcwd() + try: + os.chdir(tmpdir) + tar = tarfile.open(tarball) + _extractall(tar) + tar.close() + + # going in the directory + subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0]) + os.chdir(subdir) + log.warn('Now working in %s', subdir) + + # installing + log.warn('Installing Setuptools') + if not _python_cmd('setup.py', 'install', *install_args): + log.warn('Something went wrong during the installation.') + log.warn('See the error message above.') + # exitcode will be 2 + return 2 + finally: + os.chdir(old_wd) + shutil.rmtree(tmpdir) + + +def _build_egg(egg, tarball, to_dir): + # extracting the tarball + tmpdir = tempfile.mkdtemp() + log.warn('Extracting in %s', tmpdir) + old_wd = os.getcwd() + try: + os.chdir(tmpdir) + tar = tarfile.open(tarball) + _extractall(tar) + tar.close() + + # going in the directory + subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0]) + os.chdir(subdir) + log.warn('Now working in %s', subdir) + + # building an egg + log.warn('Building a Setuptools egg in %s', to_dir) + _python_cmd('setup.py', '-q', 'bdist_egg', '--dist-dir', to_dir) + + finally: + os.chdir(old_wd) + shutil.rmtree(tmpdir) + # returning the result + log.warn(egg) + if not os.path.exists(egg): + raise IOError('Could not build the egg.') + + +def _do_download(version, download_base, to_dir, download_delay): + egg = os.path.join(to_dir, 'setuptools-%s-py%d.%d.egg' + % (version, sys.version_info[0], sys.version_info[1])) + if not os.path.exists(egg): + tarball = download_setuptools(version, download_base, + to_dir, download_delay) + _build_egg(egg, tarball, to_dir) + sys.path.insert(0, egg) + + # Remove previously-imported pkg_resources if present (see + # https://bitbucket.org/pypa/setuptools/pull-request/7/ for details). + if 'pkg_resources' in sys.modules: + del sys.modules['pkg_resources'] + + import setuptools + setuptools.bootstrap_install_from = egg + + +def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, + to_dir=os.curdir, download_delay=15): + # making sure we use the absolute path + to_dir = os.path.abspath(to_dir) + was_imported = 'pkg_resources' in sys.modules or \ + 'setuptools' in sys.modules + try: + import pkg_resources + except ImportError: + return _do_download(version, download_base, to_dir, download_delay) + try: + pkg_resources.require("setuptools>=" + version) + return + except pkg_resources.VersionConflict: + e = sys.exc_info()[1] + if was_imported: + sys.stderr.write( + "The required version of setuptools (>=%s) is not available,\n" + "and can't be installed while this script is running. Please\n" + "install a more recent version first, using\n" + "'easy_install -U setuptools'." + "\n\n(Currently using %r)\n" % (version, e.args[0])) + sys.exit(2) + else: + del pkg_resources, sys.modules['pkg_resources'] # reload ok + return _do_download(version, download_base, to_dir, + download_delay) + except pkg_resources.DistributionNotFound: + return _do_download(version, download_base, to_dir, + download_delay) + +def download_file_powershell(url, target): + """ + Download the file at url to target using Powershell (which will validate + trust). Raise an exception if the command cannot complete. + """ + target = os.path.abspath(target) + cmd = [ + 'powershell', + '-Command', + "(new-object System.Net.WebClient).DownloadFile(%(url)r, %(target)r)" % vars(), + ] + subprocess.check_call(cmd) + +def has_powershell(): + if platform.system() != 'Windows': + return False + cmd = ['powershell', '-Command', 'echo test'] + devnull = open(os.path.devnull, 'wb') + try: + try: + subprocess.check_call(cmd, stdout=devnull, stderr=devnull) + except: + return False + finally: + devnull.close() + return True + +download_file_powershell.viable = has_powershell + +def download_file_curl(url, target): + cmd = ['curl', url, '--silent', '--output', target] + subprocess.check_call(cmd) + +def has_curl(): + cmd = ['curl', '--version'] + devnull = open(os.path.devnull, 'wb') + try: + try: + subprocess.check_call(cmd, stdout=devnull, stderr=devnull) + except: + return False + finally: + devnull.close() + return True + +download_file_curl.viable = has_curl + +def download_file_wget(url, target): + cmd = ['wget', url, '--quiet', '--output-document', target] + subprocess.check_call(cmd) + +def has_wget(): + cmd = ['wget', '--version'] + devnull = open(os.path.devnull, 'wb') + try: + try: + subprocess.check_call(cmd, stdout=devnull, stderr=devnull) + except: + return False + finally: + devnull.close() + return False + +download_file_wget.viable = has_wget + +def download_file_insecure(url, target): + """ + Use Python to download the file, even though it cannot authenticate the + connection. + """ + try: + from urllib.request import urlopen + except ImportError: + from urllib2 import urlopen + src = dst = None + try: + src = urlopen(url) + # Read/write all in one block, so we don't create a corrupt file + # if the download is interrupted. + data = src.read() + dst = open(target, "wb") + dst.write(data) + finally: + if src: + src.close() + if dst: + dst.close() + +download_file_insecure.viable = lambda: True + +def get_best_downloader(): + downloaders = [ + download_file_powershell, + download_file_curl, + download_file_wget, + download_file_insecure, + ] + + for dl in downloaders: + if dl.viable(): + return dl + +def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, + to_dir=os.curdir, delay=15, + downloader_factory=get_best_downloader): + """Download setuptools from a specified location and return its filename + + `version` should be a valid setuptools version number that is available + as an egg for download under the `download_base` URL (which should end + with a '/'). `to_dir` is the directory where the egg will be downloaded. + `delay` is the number of seconds to pause before an actual download + attempt. + + ``downloader_factory`` should be a function taking no arguments and + returning a function for downloading a URL to a target. + """ + # making sure we use the absolute path + to_dir = os.path.abspath(to_dir) + tgz_name = "setuptools-%s.tar.gz" % version + url = download_base + tgz_name + saveto = os.path.join(to_dir, tgz_name) + if not os.path.exists(saveto): # Avoid repeated downloads + log.warn("Downloading %s", url) + downloader = downloader_factory() + downloader(url, saveto) + return os.path.realpath(saveto) + + +def _extractall(self, path=".", members=None): + """Extract all members from the archive to the current working + directory and set owner, modification time and permissions on + directories afterwards. `path' specifies a different directory + to extract to. `members' is optional and must be a subset of the + list returned by getmembers(). + """ + import copy + import operator + from tarfile import ExtractError + directories = [] + + if members is None: + members = self + + for tarinfo in members: + if tarinfo.isdir(): + # Extract directories with a safe mode. + directories.append(tarinfo) + tarinfo = copy.copy(tarinfo) + tarinfo.mode = 448 # decimal for oct 0700 + self.extract(tarinfo, path) + + # Reverse sort directories. + if sys.version_info < (2, 4): + def sorter(dir1, dir2): + return cmp(dir1.name, dir2.name) + directories.sort(sorter) + directories.reverse() + else: + directories.sort(key=operator.attrgetter('name'), reverse=True) + + # Set correct owner, mtime and filemode on directories. + for tarinfo in directories: + dirpath = os.path.join(path, tarinfo.name) + try: + self.chown(tarinfo, dirpath) + self.utime(tarinfo, dirpath) + self.chmod(tarinfo, dirpath) + except ExtractError: + e = sys.exc_info()[1] + if self.errorlevel > 1: + raise + else: + self._dbg(1, "tarfile: %s" % e) + + +def _build_install_args(options): + """ + Build the arguments to 'python setup.py install' on the setuptools package + """ + install_args = [] + if options.user_install: + if sys.version_info < (2, 6): + log.warn("--user requires Python 2.6 or later") + raise SystemExit(1) + install_args.append('--user') + return install_args + +def _parse_args(): + """ + Parse the command line for options + """ + parser = optparse.OptionParser() + parser.add_option( + '--user', dest='user_install', action='store_true', default=False, + help='install in user site package (requires Python 2.6 or later)') + parser.add_option( + '--download-base', dest='download_base', metavar="URL", + default=DEFAULT_URL, + help='alternative URL from where to download the setuptools package') + parser.add_option( + '--insecure', dest='downloader_factory', action='store_const', + const=lambda: download_file_insecure, default=get_best_downloader, + help='Use internal, non-validating downloader' + ) + options, args = parser.parse_args() + # positional arguments are ignored + return options + +def main(version=DEFAULT_VERSION): + """Install or upgrade setuptools and EasyInstall""" + options = _parse_args() + tarball = download_setuptools(download_base=options.download_base, + downloader_factory=options.downloader_factory) + return _install(tarball, _build_install_args(options)) + +if __name__ == '__main__': + sys.exit(main()) diff --git a/contrib/windows-install/settings.cmd b/contrib/windows-install/settings.cmd new file mode 100644 index 00000000..32089ece --- /dev/null +++ b/contrib/windows-install/settings.cmd @@ -0,0 +1,3 @@ +set WEBOOB_VERSION=0.g +set WEBOOB=weboob-0.g-py2.7.egg +set LIST_APPLIQUATIONS_QT=qboobmsg qcineoob qcookboob qflatboob qhandjoob qhavedate qvideoob qwebcontentedit weboob-config-qt \ No newline at end of file diff --git a/contrib/windows-install/setup-weboob.bat b/contrib/windows-install/setup-weboob.bat new file mode 100644 index 00000000..a2be1815 --- /dev/null +++ b/contrib/windows-install/setup-weboob.bat @@ -0,0 +1,146 @@ +@echo off + +call settings.cmd + +echo. +echo 0.Set proxy +set/P HTTP_PROXY=Enter HTTP_PROXY if needed : +set/P HTTPS_PROXY=Enter HTTPS_PROXY if needed : + +echo. +echo 1.GNU/WGET Installation +for %%i in (wget.exe) do set wget=%%~$PATH:i +if not defined wget ( + wget-1.11.4-1-setup.exe +) + +echo. +echo 2.Check Python 2.7 Installation +set KEY_NAME=HKLM\Software\Python\PythonCore\2.7\InstallPath +REG QUERY %KEY_NAME% > nul || ( + echo 2.1 Download Python 2.7 + wget -o python_donwload http://www.python.org/ftp/python/2.7.5/python-2.7.5.msi + + echo 2.2 Setup Python 2.7 + python-2.7.5.msi + + del python-2.7.5.msi + del python_donwload + ) + +for /F "tokens=4" %%A IN ('REG QUERY %KEY_NAME%') do ( + set PythonPath=%%A +) + +echo. +echo 3.Check PyQt4 Installation +for %%i in (pyuic4.bat) do set qt=%%~$PATH:i +if not defined qt ( + + echo 3.1 Download PyQt4 + wget -o qt_download http://downloads.sourceforge.net/project/pyqt/PyQt4/PyQt-4.10.3/PyQt4-4.10.3-gpl-Py2.7-Qt4.8.5-x32.exe?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fpyqt%2Ffiles%2FPyQt4%2FPyQt-4.10.3%2F&ts=1380890340&use_mirror=garr + + echo 3.2 Setup PyQt4 + PyQt4-4.10.3-gpl-Py2.7-Qt4.8.5-x32.exe + + del PyQt4-4.10.3-gpl-Py2.7-Qt4.8.5-x32.exe + del qt_download +) + +echo. +echo 4.Check EasyInstall +if exist "%PythonPath%Scripts\easy_install.exe" ( + goto :InstallWeboobDependances +) else ( + + echo 4.1 Setup setuptools + %PythonPath%python.exe ez_setup.py || goto :InstallFailed + + del setuptools-1.1.6.tar.gz + + goto :InstallWeboobDependances +) + +:InstallWeboobDependances +echo. +echo 5.Install Weboob Dependances +echo. +echo -- cssselect +%PythonPath%Scripts\easy_install.exe cssselect || goto :InstallFailed +echo. +echo -- lxml +%PythonPath%Scripts\easy_install.exe lxml || goto :InstallFailed +echo. +echo -- dateutils +%PythonPath%Scripts\easy_install.exe dateutils || goto :InstallFailed +echo. +echo -- pyyaml +%PythonPath%Scripts\easy_install.exe pyyaml || goto :InstallFailed +echo. +echo -- html2text +%PythonPath%Scripts\easy_install.exe html2text || goto :InstallFailed +echo. +echo -- mechanize +%PythonPath%Scripts\easy_install.exe mechanize || goto :InstallFailed +echo. +echo -- gdata +%PythonPath%Scripts\easy_install.exe gdata || goto :InstallFailed +echo. +echo -- pillow +%PythonPath%Scripts\easy_install.exe pillow || goto :InstallFailed + +echo. +echo 6.Install WeBoob +%PythonPath%Scripts\easy_install.exe %WEBOOB% || goto :InstallFailed + +set StartupFolder=%AppData%\Microsoft\Windows\Start Menu\Programs +if exist "%StartupFolder%" Goto :FoundStartup +set StartupFolder=%UserProfile%\Start Menu\Programs +if exist "%StartupFolder%" Goto :FoundStartup +echo Cannot find Startup folder. +echo do not create launchers +goto :InstallSucceed + +:FoundStartup +if exist "%StartupFolder%\Weboob" ( + goto :CreateLauncher +) else ( + md "%StartupFolder%\Weboob" + goto :CreateLauncher +) + +:CreateLauncher +::for /f "delims=. tokens=1" %%i in ('dir /b "%PythonPath%\Lib\site-packages\%WEBOOB%\share\icons\hicolor\64x64\apps\q*.png"') do ( +for %%i in (%LIST_APPLIQUATIONS_QT%) do ( + echo Process %%i + + ( + echo @echo off + echo start %PythonPath%pythonw.exe %PythonPath%Scripts\%%i + ) > %%i.bat + + %PythonPath%python.exe convertPNG2ICO.py "%PythonPath%\Lib\site-packages\%WEBOOB%\share\icons\hicolor\64x64\apps\%%i.png" > nul + + if exist "%StartupFolder%\Weboob\%%i.exe" ( + del "%StartupFolder%\Weboob\%%i.exe" + ) + + "Bat_To_Exe_Converter.exe" -bat "%%i.bat" -save "%StartupFolder%\Weboob\%%i.exe" -icon "%PythonPath%\Lib\site-packages\%WEBOOB%\share\icons\hicolor\64x64\apps\%%i.ico" %%i" + del "%%i.bat" + del "%PythonPath%\Lib\site-packages\%WEBOOB%\share\icons\hicolor\64x64\apps\%%i.ico" +) + +goto :InstallSucceed + +:InstallSucceed +echo. +echo INSTALLATION PROCESS SUCCEED +goto :Quit + +:InstallFailed +echo. +echo INSTALLATION PROCESS FAILED +goto :Quit + +:Quit +pause \ No newline at end of file diff --git a/contrib/windows-install/setuptools-1.1.6.tar.gz b/contrib/windows-install/setuptools-1.1.6.tar.gz new file mode 100644 index 00000000..18c311c2 Binary files /dev/null and b/contrib/windows-install/setuptools-1.1.6.tar.gz differ diff --git a/contrib/windows-install/weboob-0.g-py2.7.egg b/contrib/windows-install/weboob-0.g-py2.7.egg new file mode 100644 index 00000000..24d602d1 Binary files /dev/null and b/contrib/windows-install/weboob-0.g-py2.7.egg differ