From 9e0ef7f722c606863c7388ac5c606c7859038ff2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 19 Jul 2014 02:15:02 +0200 Subject: Move test stuff to common directory --- module/common/pavement.py | 412 ++++++++++++++++++++++++++++++++++++++++++++ module/common/test_api.py | 20 +++ module/common/test_json.py | 48 ++++++ pavement.py | 413 --------------------------------------------- systemCheck.py | 119 ------------- testlinks.txt | 26 --- tests/test_api.py | 21 --- tests/test_json.py | 49 ------ 8 files changed, 480 insertions(+), 628 deletions(-) create mode 100644 module/common/pavement.py create mode 100644 module/common/test_api.py create mode 100644 module/common/test_json.py delete mode 100644 pavement.py delete mode 100644 systemCheck.py delete mode 100644 testlinks.txt delete mode 100644 tests/test_api.py delete mode 100644 tests/test_json.py diff --git a/module/common/pavement.py b/module/common/pavement.py new file mode 100644 index 000000000..e66eb75f4 --- /dev/null +++ b/module/common/pavement.py @@ -0,0 +1,412 @@ +# -*- coding: utf-8 -*- + +from paver.easy import * +from paver.setuputils import setup +from paver.doctools import cog + +import os +import sys +import shutil +import re +from glob import glob +from tempfile import mkdtemp +from urllib import urlretrieve +from subprocess import call, Popen, PIPE +from zipfile import ZipFile + +PROJECT_DIR = path(__file__).dirname() +sys.path.append(PROJECT_DIR) + +options = environment.options +path('pyload').mkdir() + +extradeps = [] +if sys.version_info <= (2, 5): + extradeps += 'simplejson' + +setup( + name="pyload", + version="0.4.10", + description='Fast, lightweight and full featured download manager.', + long_description=open(PROJECT_DIR / "README.md").read(), + keywords = ('pyload', 'download-manager', 'one-click-hoster', 'download'), + url="http://pyload.org", + download_url='http://pyload.org/download', + license='GPL v3', + author="pyLoad Team", + author_email="support@pyload.org", + platforms = ('Any',), + #package_dir={'pyload': 'src'}, + packages=['pyload'], + #package_data=find_package_data(), + #data_files=[], + include_package_data=True, + exclude_package_data={'pyload': ['docs*', 'scripts*', 'tests*']}, #exluced from build but not from sdist + # 'bottle >= 0.10.0' not in list, because its small and contain little modifications + install_requires=['thrift >= 0.8.0', 'jinja2', 'pycurl', 'Beaker', 'BeautifulSoup >= 3.2, < 3.3'] + extradeps, + extras_require={ + 'SSL': ["pyOpenSSL"], + 'DLC': ['pycrypto'], + 'lightweight webserver': ['bjoern'], + 'RSS plugins': ['feedparser'], + }, + #setup_requires=["setuptools_hg"], + entry_points={ + 'console_scripts': [ + 'pyLoadCore = pyLoadCore:main', + 'pyLoadCli = pyLoadCli:main' + ]}, + zip_safe=False, + classifiers=[ + "Development Status :: 5 - Production/Stable", + "Topic :: Internet :: WWW/HTTP", + "Environment :: Console", + "Environment :: Web Environment", + "Intended Audience :: End Users/Desktop", + "License :: OSI Approved :: GNU General Public License (GPL)", + "Operating System :: OS Independent", + "Programming Language :: Python :: 2" + ] +) + +options( + sphinx=Bunch( + builddir="_build", + sourcedir="" + ), + get_source=Bunch( + src="https://bitbucket.org/spoob/pyload/get/tip.zip", + rev=None, + clean=False + ), + thrift=Bunch( + path="../thrift/trunk/compiler/cpp/thrift", + gen="" + ), + virtualenv=Bunch( + dir="env", + python="python2", + virtual="virtualenv2", + ), + cog=Bunch( + pattern="*.py", + ) +) + +# xgettext args +xargs = ["--language=Python", "--add-comments=L10N", + "--from-code=utf-8", "--copyright-holder=pyLoad Team", "--package-name=pyLoad", + "--package-version=%s" % options.version, "--msgid-bugs-address='bugs@pyload.org'"] + +@task +@needs('cog') +def html(): + """Build html documentation""" + module = path("docs") / "module" + module.rmtree() + call_task('paver.doctools.html') + + +@task +@cmdopts([ + ('src=', 's', 'Url to source'), + ('rev=', 'r', "HG revision"), + ("clean", 'c', 'Delete old source folder') +]) +def get_source(options): + """ Downloads pyload source from bitbucket tip or given rev""" + if options.rev: options.url = "https://bitbucket.org/spoob/pyload/get/%s.zip" % options.rev + + pyload = path("pyload") + + if len(pyload.listdir()) and not options.clean: + return + elif pyload.exists(): + pyload.rmtree() + + urlretrieve(options.src, "pyload_src.zip") + zip = ZipFile("pyload_src.zip") + zip.extractall() + path("pyload_src.zip").remove() + + folder = [x for x in path(".").dirs() if x.name.startswith("spoob-pyload-")][0] + folder.move(pyload) + + change_mode(pyload, 0644) + change_mode(pyload, 0755, folder=True) + + for file in pyload.files(): + if file.name.endswith(".py"): + file.chmod(0755) + + (pyload / ".hgtags").remove() + (pyload / ".gitignore").remove() + #(pyload / "docs").rmtree() + + f = open(pyload / "__init__.py", "wb") + f.close() + + #options.setup.packages = find_packages() + #options.setup.package_data = find_package_data() + + +@task +@needs('clean', 'generate_setup', 'minilib', 'get_source', 'setuptools.command.sdist') +def sdist(): + """ Build source code package with distutils """ + + +@task +@cmdopts([ + ('path=', 'p', 'Thrift path'), + ('gen=', 'g', "Extra --gen option") +]) +def thrift(options): + """ Generate Thrift stubs """ + + print "add import for TApplicationException manually as long it is not fixed" + + outdir = path("module") / "remote" / "thriftbackend" + (outdir / "gen-py").rmtree() + + cmd = [options.thrift.path, "-strict", "-o", outdir, "--gen", "py:slots, dynamic", outdir / "pyload.thrift"] + + if options.gen: + cmd.insert(len(cmd) - 1, "--gen") + cmd.insert(len(cmd) - 1, options.gen) + + print "running", cmd + + p = Popen(cmd) + p.communicate() + + (outdir / "thriftgen").rmtree() + (outdir / "gen-py").move(outdir / "thriftgen") + + #create light ttypes + from module.remote.socketbackend.create_ttypes import main + main() + +@task +def compile_js(): + """ Compile .coffee files to javascript""" + + root = path("module") / "web" / "media" / "js" + for f in root.glob("*.coffee"): + print "generate", f + coffee = Popen(["coffee", "-cbs"], stdin=open(f, "rb"), stdout=PIPE) + yui = Popen(["yuicompressor", "--type", "js"], stdin=coffee.stdout, stdout=PIPE) + coffee.stdout.close() + content = yui.communicate()[0] + with open(root / f.name.replace(".coffee", ".js"), "wb") as js: + js.write("{% autoescape true %}\n") + js.write(content) + js.write("\n{% endautoescape %}") + + +@task +def generate_locale(): + """ Generates localization files """ + + EXCLUDE = ["BeautifulSoup.py", "module/cli", "web/locale", "web/ajax", "web/cnl", "web/pyload", + "setup.py"] + makepot("core", path("module"), EXCLUDE, "./pyLoadCore.py\n") + + makepot("cli", path("module") / "cli", [], includes="./pyLoadCli.py\n") + makepot("setup", "", [], includes="./module/setup.py\n") + + EXCLUDE = ["ServerThread.py", "web/media/default"] + + # strings from js files + strings = set() + + for fi in path("module/web").walkfiles(): + if not fi.name.endswith(".js") and not fi.endswith(".coffee"): continue + with open(fi, "rb") as c: + content = c.read() + + strings.update(re.findall(r"_\s*\(\s*\"([^\"]+)", content)) + strings.update(re.findall(r"_\s*\(\s*\'([^\']+)", content)) + + trans = path("module") / "web" / "translations.js" + + with open(trans, "wb") as js: + for s in strings: + js.write('_("%s")\n' % s) + + makepot("django", path("module/web"), EXCLUDE, "./%s\n" % trans.relpath(), [".py", ".html"], ["--language=Python"]) + + trans.remove() + + path("includes.txt").remove() + + print "Locale generated" + + +@task +@cmdopts([ + ('key=', 'k', 'api key') +]) +def upload_translations(options): + """ Uploads the locale files to translation server """ + tmp = path(mkdtemp()) + + shutil.copy('locale/crowdin.yaml', tmp) + os.mkdir(tmp / 'pyLoad') + for f in glob('locale/*.pot'): + if os.path.isfile(f): + shutil.copy(f, tmp / 'pyLoad') + + config = tmp / 'crowdin.yaml' + content = open(config, 'rb').read() + content = content.format(key=options.key, tmp=tmp) + f = open(config, 'wb') + f.write(content) + f.close() + + call(['crowdin-cli', '-c', config, 'upload', 'source']) + + shutil.rmtree(tmp) + + print "Translations uploaded" + + +@task +@cmdopts([ + ('key=', 'k', 'api key') +]) +def download_translations(options): + """ Downloads the translated files from translation server """ + tmp = path(mkdtemp()) + + shutil.copy('locale/crowdin.yaml', tmp) + os.mkdir(tmp / 'pyLoad') + for f in glob('locale/*.pot'): + if os.path.isfile(f): + shutil.copy(f, tmp / 'pyLoad') + + config = tmp / 'crowdin.yaml' + content = open(config, 'rb').read() + content = content.format(key=options.key, tmp=tmp) + f = open(config, 'wb') + f.write(content) + f.close() + + call(['crowdin-cli', '-c', config, 'download']) + + for language in (tmp / 'pyLoad').listdir(): + if not language.isdir(): + continue + + target = path('locale') / language.basename() + print "Copy language %s" % target + if target.exists(): + shutil.rmtree(target) + + shutil.copytree(language, target) + + shutil.rmtree(tmp) + + +@task +def compile_translations(): + """ Compile PO files to MO """ + for language in path('locale').listdir(): + if not language.isdir(): + continue + + for f in glob(language / 'LC_MESSAGES' / '*.po'): + print "Compiling %s" % f + call(['msgfmt', '-o', f.replace('.po', '.mo'), f]) + + +@task +def tests(): + call(["nosetests2"]) + +@task +def virtualenv(options): + """Setup virtual environment""" + if path(options.dir).exists(): + return + + call([options.virtual, "--no-site-packages", "--python", options.python, options.dir]) + print "$ source %s/bin/activate" % options.dir + + +@task +def clean_env(): + """Deletes the virtual environment""" + env = path(options.virtualenv.dir) + if env.exists(): + env.rmtree() + + +@task +@needs('generate_setup', 'minilib', 'get_source', 'virtualenv') +def env_install(): + """Install pyLoad into the virtualenv""" + venv = options.virtualenv + call([path(venv.dir) / "bin" / "easy_install", "."]) + + +@task +def clean(): + """Cleans build directories""" + path("build").rmtree() + path("dist").rmtree() + + +#helper functions + +def walk_trans(path, EXCLUDE, endings=[".py"]): + result = "" + + for f in path.walkfiles(): + if [True for x in EXCLUDE if x in f.dirname().relpath()]: continue + if f.name in EXCLUDE: continue + + for e in endings: + if f.name.endswith(e): + result += "./%s\n" % f.relpath() + break + + return result + + +def makepot(domain, p, excludes=[], includes="", endings=[".py"], xxargs=[]): + print "Generate %s.pot" % domain + + f = open("includes.txt", "wb") + if includes: + f.write(includes) + + if p: + f.write(walk_trans(path(p), excludes, endings)) + + f.close() + + call(["xgettext", "--files-from=includes.txt", "--default-domain=%s" % domain] + xargs + xxargs) + + # replace charset und move file + with open("%s.po" % domain, "rb") as f: + content = f.read() + + path("%s.po" % domain).remove() + content = content.replace("charset=CHARSET", "charset=UTF-8") + + with open("locale/%s.pot" % domain, "wb") as f: + f.write(content) + + +def change_owner(dir, uid, gid): + for p in dir.walk(): + p.chown(uid, gid) + + +def change_mode(dir, mode, folder=False): + for p in dir.walk(): + if folder and p.isdir(): + p.chmod(mode) + elif p.isfile() and not folder: + p.chmod(mode) diff --git a/module/common/test_api.py b/module/common/test_api.py new file mode 100644 index 000000000..f8901f731 --- /dev/null +++ b/module/common/test_api.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- + +from module.common import APIExerciser +from nose.tools import nottest + + +class TestApi: + + def __init__(self): + self.api = APIExerciser.APIExerciser(None, True, "TestUser", "pwhere") + + def test_login(self): + assert self.api.api.login("crapp", "wrong pw") is False + + #takes really long, only test when needed + @nottest + def test_random(self): + + for i in range(0, 100): + self.api.testAPI() diff --git a/module/common/test_json.py b/module/common/test_json.py new file mode 100644 index 000000000..320a42d4f --- /dev/null +++ b/module/common/test_json.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +from urllib import urlencode +from urllib2 import urlopen, HTTPError +from json import loads + +from logging import log + +url = "http://localhost:8001/api/%s" + +class TestJson: + + def call(self, name, post=None): + if not post: post = {} + post["session"] = self.key + u = urlopen(url % name, data=urlencode(post)) + return loads(u.read()) + + def setUp(self): + u = urlopen(url % "login", data=urlencode({"username": "TestUser", "password": "pwhere"})) + self.key = loads(u.read()) + assert self.key is not False + + def test_wronglogin(self): + u = urlopen(url % "login", data=urlencode({"username": "crap", "password": "wrongpw"})) + assert loads(u.read()) is False + + def test_access(self): + try: + urlopen(url % "getServerVersion") + except HTTPError, e: + assert e.code == 403 + else: + assert False + + def test_status(self): + ret = self.call("statusServer") + log(1, str(ret)) + assert "pause" in ret + assert "queue" in ret + + def test_unknown_method(self): + try: + self.call("notExisting") + except HTTPError, e: + assert e.code == 404 + else: + assert False diff --git a/pavement.py b/pavement.py deleted file mode 100644 index 9f8ebacbf..000000000 --- a/pavement.py +++ /dev/null @@ -1,413 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from paver.easy import * -from paver.setuputils import setup -from paver.doctools import cog - -import os -import sys -import shutil -import re -from glob import glob -from tempfile import mkdtemp -from urllib import urlretrieve -from subprocess import call, Popen, PIPE -from zipfile import ZipFile - -PROJECT_DIR = path(__file__).dirname() -sys.path.append(PROJECT_DIR) - -options = environment.options -path('pyload').mkdir() - -extradeps = [] -if sys.version_info <= (2, 5): - extradeps += 'simplejson' - -setup( - name="pyload", - version="0.4.10", - description='Fast, lightweight and full featured download manager.', - long_description=open(PROJECT_DIR / "README.md").read(), - keywords = ('pyload', 'download-manager', 'one-click-hoster', 'download'), - url="http://pyload.org", - download_url='http://pyload.org/download', - license='GPL v3', - author="pyLoad Team", - author_email="support@pyload.org", - platforms = ('Any',), - #package_dir={'pyload': 'src'}, - packages=['pyload'], - #package_data=find_package_data(), - #data_files=[], - include_package_data=True, - exclude_package_data={'pyload': ['docs*', 'scripts*', 'tests*']}, #exluced from build but not from sdist - # 'bottle >= 0.10.0' not in list, because its small and contain little modifications - install_requires=['thrift >= 0.8.0', 'jinja2', 'pycurl', 'Beaker', 'BeautifulSoup >= 3.2, < 3.3'] + extradeps, - extras_require={ - 'SSL': ["pyOpenSSL"], - 'DLC': ['pycrypto'], - 'lightweight webserver': ['bjoern'], - 'RSS plugins': ['feedparser'], - }, - #setup_requires=["setuptools_hg"], - entry_points={ - 'console_scripts': [ - 'pyLoadCore = pyLoadCore:main', - 'pyLoadCli = pyLoadCli:main' - ]}, - zip_safe=False, - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Topic :: Internet :: WWW/HTTP", - "Environment :: Console", - "Environment :: Web Environment", - "Intended Audience :: End Users/Desktop", - "License :: OSI Approved :: GNU General Public License (GPL)", - "Operating System :: OS Independent", - "Programming Language :: Python :: 2" - ] -) - -options( - sphinx=Bunch( - builddir="_build", - sourcedir="" - ), - get_source=Bunch( - src="https://bitbucket.org/spoob/pyload/get/tip.zip", - rev=None, - clean=False - ), - thrift=Bunch( - path="../thrift/trunk/compiler/cpp/thrift", - gen="" - ), - virtualenv=Bunch( - dir="env", - python="python2", - virtual="virtualenv2", - ), - cog=Bunch( - pattern="*.py", - ) -) - -# xgettext args -xargs = ["--language=Python", "--add-comments=L10N", - "--from-code=utf-8", "--copyright-holder=pyLoad Team", "--package-name=pyLoad", - "--package-version=%s" % options.version, "--msgid-bugs-address='bugs@pyload.org'"] - -@task -@needs('cog') -def html(): - """Build html documentation""" - module = path("docs") / "module" - module.rmtree() - call_task('paver.doctools.html') - - -@task -@cmdopts([ - ('src=', 's', 'Url to source'), - ('rev=', 'r', "HG revision"), - ("clean", 'c', 'Delete old source folder') -]) -def get_source(options): - """ Downloads pyload source from bitbucket tip or given rev""" - if options.rev: options.url = "https://bitbucket.org/spoob/pyload/get/%s.zip" % options.rev - - pyload = path("pyload") - - if len(pyload.listdir()) and not options.clean: - return - elif pyload.exists(): - pyload.rmtree() - - urlretrieve(options.src, "pyload_src.zip") - zip = ZipFile("pyload_src.zip") - zip.extractall() - path("pyload_src.zip").remove() - - folder = [x for x in path(".").dirs() if x.name.startswith("spoob-pyload-")][0] - folder.move(pyload) - - change_mode(pyload, 0644) - change_mode(pyload, 0755, folder=True) - - for file in pyload.files(): - if file.name.endswith(".py"): - file.chmod(0755) - - (pyload / ".hgtags").remove() - (pyload / ".gitignore").remove() - #(pyload / "docs").rmtree() - - f = open(pyload / "__init__.py", "wb") - f.close() - - #options.setup.packages = find_packages() - #options.setup.package_data = find_package_data() - - -@task -@needs('clean', 'generate_setup', 'minilib', 'get_source', 'setuptools.command.sdist') -def sdist(): - """ Build source code package with distutils """ - - -@task -@cmdopts([ - ('path=', 'p', 'Thrift path'), - ('gen=', 'g', "Extra --gen option") -]) -def thrift(options): - """ Generate Thrift stubs """ - - print "add import for TApplicationException manually as long it is not fixed" - - outdir = path("module") / "remote" / "thriftbackend" - (outdir / "gen-py").rmtree() - - cmd = [options.thrift.path, "-strict", "-o", outdir, "--gen", "py:slots, dynamic", outdir / "pyload.thrift"] - - if options.gen: - cmd.insert(len(cmd) - 1, "--gen") - cmd.insert(len(cmd) - 1, options.gen) - - print "running", cmd - - p = Popen(cmd) - p.communicate() - - (outdir / "thriftgen").rmtree() - (outdir / "gen-py").move(outdir / "thriftgen") - - #create light ttypes - from module.remote.socketbackend.create_ttypes import main - main() - -@task -def compile_js(): - """ Compile .coffee files to javascript""" - - root = path("module") / "web" / "media" / "js" - for f in root.glob("*.coffee"): - print "generate", f - coffee = Popen(["coffee", "-cbs"], stdin=open(f, "rb"), stdout=PIPE) - yui = Popen(["yuicompressor", "--type", "js"], stdin=coffee.stdout, stdout=PIPE) - coffee.stdout.close() - content = yui.communicate()[0] - with open(root / f.name.replace(".coffee", ".js"), "wb") as js: - js.write("{% autoescape true %}\n") - js.write(content) - js.write("\n{% endautoescape %}") - - -@task -def generate_locale(): - """ Generates localization files """ - - EXCLUDE = ["BeautifulSoup.py", "module/cli", "web/locale", "web/ajax", "web/cnl", "web/pyload", - "setup.py"] - makepot("core", path("module"), EXCLUDE, "./pyLoadCore.py\n") - - makepot("cli", path("module") / "cli", [], includes="./pyLoadCli.py\n") - makepot("setup", "", [], includes="./module/setup.py\n") - - EXCLUDE = ["ServerThread.py", "web/media/default"] - - # strings from js files - strings = set() - - for fi in path("module/web").walkfiles(): - if not fi.name.endswith(".js") and not fi.endswith(".coffee"): continue - with open(fi, "rb") as c: - content = c.read() - - strings.update(re.findall(r"_\s*\(\s*\"([^\"]+)", content)) - strings.update(re.findall(r"_\s*\(\s*\'([^\']+)", content)) - - trans = path("module") / "web" / "translations.js" - - with open(trans, "wb") as js: - for s in strings: - js.write('_("%s")\n' % s) - - makepot("django", path("module/web"), EXCLUDE, "./%s\n" % trans.relpath(), [".py", ".html"], ["--language=Python"]) - - trans.remove() - - path("includes.txt").remove() - - print "Locale generated" - - -@task -@cmdopts([ - ('key=', 'k', 'api key') -]) -def upload_translations(options): - """ Uploads the locale files to translation server """ - tmp = path(mkdtemp()) - - shutil.copy('locale/crowdin.yaml', tmp) - os.mkdir(tmp / 'pyLoad') - for f in glob('locale/*.pot'): - if os.path.isfile(f): - shutil.copy(f, tmp / 'pyLoad') - - config = tmp / 'crowdin.yaml' - content = open(config, 'rb').read() - content = content.format(key=options.key, tmp=tmp) - f = open(config, 'wb') - f.write(content) - f.close() - - call(['crowdin-cli', '-c', config, 'upload', 'source']) - - shutil.rmtree(tmp) - - print "Translations uploaded" - - -@task -@cmdopts([ - ('key=', 'k', 'api key') -]) -def download_translations(options): - """ Downloads the translated files from translation server """ - tmp = path(mkdtemp()) - - shutil.copy('locale/crowdin.yaml', tmp) - os.mkdir(tmp / 'pyLoad') - for f in glob('locale/*.pot'): - if os.path.isfile(f): - shutil.copy(f, tmp / 'pyLoad') - - config = tmp / 'crowdin.yaml' - content = open(config, 'rb').read() - content = content.format(key=options.key, tmp=tmp) - f = open(config, 'wb') - f.write(content) - f.close() - - call(['crowdin-cli', '-c', config, 'download']) - - for language in (tmp / 'pyLoad').listdir(): - if not language.isdir(): - continue - - target = path('locale') / language.basename() - print "Copy language %s" % target - if target.exists(): - shutil.rmtree(target) - - shutil.copytree(language, target) - - shutil.rmtree(tmp) - - -@task -def compile_translations(): - """ Compile PO files to MO """ - for language in path('locale').listdir(): - if not language.isdir(): - continue - - for f in glob(language / 'LC_MESSAGES' / '*.po'): - print "Compiling %s" % f - call(['msgfmt', '-o', f.replace('.po', '.mo'), f]) - - -@task -def tests(): - call(["nosetests2"]) - -@task -def virtualenv(options): - """Setup virtual environment""" - if path(options.dir).exists(): - return - - call([options.virtual, "--no-site-packages", "--python", options.python, options.dir]) - print "$ source %s/bin/activate" % options.dir - - -@task -def clean_env(): - """Deletes the virtual environment""" - env = path(options.virtualenv.dir) - if env.exists(): - env.rmtree() - - -@task -@needs('generate_setup', 'minilib', 'get_source', 'virtualenv') -def env_install(): - """Install pyLoad into the virtualenv""" - venv = options.virtualenv - call([path(venv.dir) / "bin" / "easy_install", "."]) - - -@task -def clean(): - """Cleans build directories""" - path("build").rmtree() - path("dist").rmtree() - - -#helper functions - -def walk_trans(path, EXCLUDE, endings=[".py"]): - result = "" - - for f in path.walkfiles(): - if [True for x in EXCLUDE if x in f.dirname().relpath()]: continue - if f.name in EXCLUDE: continue - - for e in endings: - if f.name.endswith(e): - result += "./%s\n" % f.relpath() - break - - return result - - -def makepot(domain, p, excludes=[], includes="", endings=[".py"], xxargs=[]): - print "Generate %s.pot" % domain - - f = open("includes.txt", "wb") - if includes: - f.write(includes) - - if p: - f.write(walk_trans(path(p), excludes, endings)) - - f.close() - - call(["xgettext", "--files-from=includes.txt", "--default-domain=%s" % domain] + xargs + xxargs) - - # replace charset und move file - with open("%s.po" % domain, "rb") as f: - content = f.read() - - path("%s.po" % domain).remove() - content = content.replace("charset=CHARSET", "charset=UTF-8") - - with open("locale/%s.pot" % domain, "wb") as f: - f.write(content) - - -def change_owner(dir, uid, gid): - for p in dir.walk(): - p.chown(uid, gid) - - -def change_mode(dir, mode, folder=False): - for p in dir.walk(): - if folder and p.isdir(): - p.chmod(mode) - elif p.isfile() and not folder: - p.chmod(mode) diff --git a/systemCheck.py b/systemCheck.py deleted file mode 100644 index 4b4144c16..000000000 --- a/systemCheck.py +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import os -import subprocess -import sys - -#from module import InitHomeDir - -#very ugly prints, but at least it works with python 3 - - -def main(): - print("##### System Information #####\n") - print("Platform:", sys.platform) - print("Operating System:", os.name) - print("Python:", sys.version.replace("\n", "") + "\n") - - try: - import pycurl - print("pycurl:", pycurl.version) - except: - print("pycurl:", "missing") - - try: - import Crypto - print("py-crypto:", Crypto.__version__) - except: - print("py-crypto:", "missing") - - try: - import OpenSSL - print("OpenSSL:", OpenSSL.version.__version__) - except: - print("OpenSSL:", "missing") - - try: - from PIL import Image - print("image libary:", Image.VERSION) - except: - print("image libary:", "missing") - - print("\n\n##### System Status #####") - print("\n## pyLoadCore ##") - - core_err = [] - core_info = [] - - if sys.version_info > (2, 7): - core_err.append("Your python version is to new, Please use Python 2.6/2.7") - - if sys.version_info < (2, 5): - core_err.append("Your python version is to old, Please use at least Python 2.5") - - try: - import pycurl - except: - core_err.append("Please install py-curl to use pyLoad.") - - try: - from pycurl import AUTOREFERER - except: - core_err.append("Your py-curl version is to old, please upgrade!") - - try: - from PIL import Image - except: - core_err.append("Please install py-imaging/pil to use Hoster, which uses captchas.") - - pipe = subprocess.PIPE - try: - p = subprocess.call(["tesseract"], stdout=pipe, stderr=pipe) - except: - core_err.append("Please install tesseract to use Hoster, which uses captchas.") - - try: - import OpenSSL - except: - core_info.append("Install OpenSSL if you want to create a secure connection to the core.") - - if core_err: - print("The system check has detected some errors:\n") - for err in core_err: - print(err) - else: - print("No Problems detected, pyLoadCore should work fine.") - - if core_info: - print("\nPossible improvements for pyload:\n") - for line in core_info: - print(line) - - print("\n## Webinterface ##") - - web_err = [] - web_info = [] - - try: - import flup - except: - web_info.append("Install Flup to use FastCGI or optional webservers.") - - if web_err: - print("The system check has detected some errors:\n") - for err in web_err: - print(err) - else: - print("No Problems detected, Webinterface should work fine.") - - if web_info: - print("\nPossible improvements for webinterface:\n") - for line in web_info: - print(line) - - -if __name__ == "__main__": - main() - - raw_input("Press Enter to Exit.") diff --git a/testlinks.txt b/testlinks.txt deleted file mode 100644 index 428cf63ea..000000000 --- a/testlinks.txt +++ /dev/null @@ -1,26 +0,0 @@ -sha1: - 961486646bf3c1d5d7a45ec32bb62e1bc4f2d894 random.bin -md5: - d76505d0869f9f928a17d42d66326307 random.bin - -please save bandwith on our server, -use this link only for remote uploads to new hoster -http://get.pyload.org/static/random.bin ---------------------------------------- -http://netload.in/datei9XirAJZs79/random.bin.htm -http://ul.to/file/o41isx -http://rapidshare.com/files/445996776/random.bin -http://dl.free.fr/d4aL5dyXY -http://www.duckload.com/dl/QggW2 -http://files.mail.ru/32EW66 -http://www.fileserve.com/file/MxjZXjX -http://www.4shared.com/file/-O5CBhQV/random.html -http://hotfile.com/dl/101569859/2e01f04/random.bin.html -http://www.megaupload.com/?d=1JZLOP3B -http://www.share.cx/files/235687689252/random.bin.html -http://www.share-online.biz/download.php?id=PTCOX1GL6XAH -http://www.shragle.com/files/f899389b/random.bin -http://www10.zippyshare.com/v/76557688/file.html -http://yourfiles.to/?d=312EC6E911 -http://depositfiles.com/files/k8la98953 -http://uploading.com/files/3896f5a1/random.bin/ diff --git a/tests/test_api.py b/tests/test_api.py deleted file mode 100644 index 99e84b3ab..000000000 --- a/tests/test_api.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from module.common import APIExerciser -from nose.tools import nottest - - -class TestApi: - - def __init__(self): - self.api = APIExerciser.APIExerciser(None, True, "TestUser", "pwhere") - - def test_login(self): - assert self.api.api.login("crapp", "wrong pw") is False - - #takes really long, only test when needed - @nottest - def test_random(self): - - for i in range(0, 100): - self.api.testAPI() diff --git a/tests/test_json.py b/tests/test_json.py deleted file mode 100644 index d06457473..000000000 --- a/tests/test_json.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from urllib import urlencode -from urllib2 import urlopen, HTTPError -from json import loads - -from logging import log - -url = "http://localhost:8001/api/%s" - -class TestJson: - - def call(self, name, post=None): - if not post: post = {} - post["session"] = self.key - u = urlopen(url % name, data=urlencode(post)) - return loads(u.read()) - - def setUp(self): - u = urlopen(url % "login", data=urlencode({"username": "TestUser", "password": "pwhere"})) - self.key = loads(u.read()) - assert self.key is not False - - def test_wronglogin(self): - u = urlopen(url % "login", data=urlencode({"username": "crap", "password": "wrongpw"})) - assert loads(u.read()) is False - - def test_access(self): - try: - urlopen(url % "getServerVersion") - except HTTPError, e: - assert e.code == 403 - else: - assert False - - def test_status(self): - ret = self.call("statusServer") - log(1, str(ret)) - assert "pause" in ret - assert "queue" in ret - - def test_unknown_method(self): - try: - self.call("notExisting") - except HTTPError, e: - assert e.code == 404 - else: - assert False -- cgit v1.2.3