diff --git a/server/__init__.py b/server/__init__.py index 4d4ce6f..d3bad95 100644 --- a/server/__init__.py +++ b/server/__init__.py @@ -1,2 +1,2 @@ -import server -import cli +from . import server +from . import cli diff --git a/server/cli.py b/server/cli.py index e2badb9..5b6e3c3 100644 --- a/server/cli.py +++ b/server/cli.py @@ -9,10 +9,10 @@ logger = logging.getLogger('cli') CWD = os.getcwd() -import forge -import maint -from config_manager import get_config -import server +from techrec import forge +from techrec import maint +from .config_manager import get_config +from techrec import server def pre_check_permissions(): @@ -84,6 +84,7 @@ def common_pre(): def main(): parser = ArgumentParser(description='creates mp3 from live recordings') parser.add_argument('--verbose', '-v', action='count', + default=0, help='Increase verbosity; can be used multiple times') parser.add_argument('--pretend', '-p', action='store_true', default=False, help='Only pretend; no real action will be done') diff --git a/server/default_config.py b/server/default_config.py index 6a7f6ca..2ac5eb9 100644 --- a/server/default_config.py +++ b/server/default_config.py @@ -33,7 +33,5 @@ try: if resource_isdir('techrec', 'pages'): STATIC_PAGES = resource_filename('techrec', 'pages') STATIC_FILES = resource_filename('techrec', 'static') - else: - print "invece dice", resource_filename('techrec', 'static') except ImportError: logging.exception("Error loading resources from installed part") diff --git a/server/forge.py b/server/forge.py index aaf1179..c174f73 100644 --- a/server/forge.py +++ b/server/forge.py @@ -4,7 +4,7 @@ import os from subprocess import Popen import logging -from config_manager import get_config +from .config_manager import get_config def get_timefile_exact(time): diff --git a/server/maint.py b/server/maint.py index 688a73e..16d80b1 100644 --- a/server/maint.py +++ b/server/maint.py @@ -1,10 +1,11 @@ +from __future__ import print_function import sys import logging from sqlalchemy import inspect -from config_manager import get_config -from techrec import RecDB +from .config_manager import get_config +from .techrec import RecDB def cleanold_cmd(options): log = logging.getLogger('cleanold') @@ -14,7 +15,7 @@ def cleanold_cmd(options): count = len(res) if options.pretend: for rec in res: - print rec + print(rec) else: for rec in res: logging.info("Deleting " + str(rec)) diff --git a/server/processqueue.py b/server/processqueue.py index cf55bd7..d5bbcf4 100644 --- a/server/processqueue.py +++ b/server/processqueue.py @@ -40,11 +40,11 @@ class JobQueue(object): def simulate_long_job(recid=None, starttime=None, endtime=None, name='', filename=None): from time import sleep - print "evviva " + name + print("evviva " + name) sleep(2) - print "lavoro su " + name + print("lavoro su " + name) sleep(2) - print "done su " + name + print("done su " + name) _queue = None @@ -60,15 +60,15 @@ if __name__ == '__main__': def sleep(n): import time - print "Inizio %d" % n + print("Inizio %d" % n) time.sleep(n) - print "Finisco %d" % n + print("Finisco %d" % n) return n get_process_queue().submit(sleep, 3) get_process_queue().submit(sleep, 3) get_process_queue().join() - print get_process_queue().jobs + print(get_process_queue().jobs) delta = (datetime.now() - n).total_seconds() - print delta + print(delta) assert 5 < delta < 7 diff --git a/server/server.py b/server/server.py index 7581c9d..e27da13 100644 --- a/server/server.py +++ b/server/server.py @@ -14,10 +14,10 @@ botlog.setLevel(logging.INFO) botlog.addHandler(logging.StreamHandler(sys.stdout)) bottle._stderr = lambda x: botlog.info(x.strip()) -from techrec import Rec, RecDB -from processqueue import get_process_queue -from forge import create_mp3 -from config_manager import get_config +from .techrec import Rec, RecDB +from .processqueue import get_process_queue +from .forge import create_mp3 +from .config_manager import get_config def date_read(s): diff --git a/server/techrec.py b/server/techrec.py index e5c2ffd..00ff634 100644 --- a/server/techrec.py +++ b/server/techrec.py @@ -1,6 +1,7 @@ ''' This module contains DB logic ''' +from __future__ import print_function import logging from datetime import datetime, timedelta @@ -11,7 +12,7 @@ from sqlalchemy import create_engine, Column, Integer, String, DateTime, inspect from sqlalchemy.orm import sessionmaker from sqlalchemy.ext.declarative import declarative_base -from config_manager import get_config +from .config_manager import get_config PAGESIZE = 10 @@ -218,7 +219,7 @@ class RecDB: return ret def get_err(self): - print "DB error: %s" % (self.err) + print("DB error: %s" % (self.err)) t = self.err self.err = "" return t @@ -227,25 +228,25 @@ class RecDB: if __name__ == "__main__": def printall(queryres): for record in queryres: - print "Record: %s" % record + print("Record: %s" % record) db = RecDB() - _mytime = datetime(2014, 05, 23, 15, 12, 17) - _endtime = datetime(2014, 05, 24, 17, 45, 17) + _mytime = datetime(2014, 5, 23, 15, 12, 17) + _endtime = datetime(2014, 5, 24, 17, 45, 17) a = Rec(name="Mimmo1", starttime=_mytime, endtime=_endtime) printall(db._search()) sys.exit("End test job") # a = Rec(name="Mimmo1", starttime=_mytime, endtime=None) - print "Aggiunto", db.add(a) + print("Aggiunto", db.add(a)) printall(db.get_all(page_size=5, page=0)) - print "Mimmo " + print("Mimmo ") printall(db._search(name="Mimmo1")) - print "Search" + print("Search") printall(db._search(name="Mimmo1", - starttime=datetime(2014, 05, 24, 15, 16, 1) )) + starttime=datetime(2014, 5, 24, 15, 16, 1) )) a = db.get_by_id(5) a.start() db.delete(1) diff --git a/server/test_forge.py b/server/test_forge.py index 9fd6225..1238a76 100644 --- a/server/test_forge.py +++ b/server/test_forge.py @@ -4,7 +4,7 @@ from nose.tools import raises, eq_ from forge import get_files_and_intervals, get_timefile_exact, round_timefile,\ get_timefile, mp3_join -from config_manager import get_config +from .config_manager import get_config eight = datetime(2014, 5, 30, 20) nine = datetime(2014, 5, 30, 21) diff --git a/setup.py b/setup.py index 06a1d3f..2cef948 100644 --- a/setup.py +++ b/setup.py @@ -14,10 +14,9 @@ setup( packages=["techrec"], package_dir={"techrec": "server"}, install_requires=[ - "Paste==1.7.5.1", + "Paste~=3.2", "SQLAlchemy==0.8.3", - "bottle==0.11.6", - "wsgiref==0.1.2", + "bottle~=0.12", ], classifiers=["Programming Language :: Python :: 2.7"], entry_points={"console_scripts": ["techrec = techrec.cli:main"]},