def init_base(): init_logging() mainlog.setLevel(logging.INFO) load_configuration("server.cfg") parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, description='This is an Horse! migration script.', epilog="For example --db-url {}".format( configuration.get("Database", "admin_url"))) parser.add_argument('--db-url', default=configuration.database_url, help='Database URL') args = parser.parse_args() mainlog.info("Connecting to {}".format(args.db_url)) init_i18n() from koi.db_mapping import metadata init_db_session(args.db_url, metadata, False) # True or configuration.echo_query)
from datetime import date import argparse from sqlalchemy.sql import select, func, and_, or_ from koi.base_logging import mainlog, init_logging from koi.Configurator import init_i18n, load_configuration, configuration, resource_dir init_logging() init_i18n() load_configuration() from koi.db_mapping import metadata from koi.datalayer.database_session import init_db_session, db_engine, session from koi.datalayer.supplier_mapping import Supplier from koi.datalayer.supply_order_mapping import SupplyOrderPart, SupplyOrder import argparse parser = argparse.ArgumentParser( description='This is an Horse! migration script.') parser.add_argument('--db-url', default=configuration.database_url, help='Database connection URL {}'.format( configuration.database_url)) def alter_structure(): try: session().connection().execute("drop table horse.supplier_orders") session().commit()
Building with pyinstaller : set PYTHONPATH=c:\PORT-STC\PRIVATE\PL\horse pyinstaller --clean --onedir koi\server\service_win32.py """ if __name__ == '__main__': init_server_directory() if len( sys.argv ) == 1: # No parameters passed, that's when Windows itself starts the service. init_logging("webserver.log", console_log=False) else: init_logging("webserver.log", console_log=True) mainlog.setLevel(logging.DEBUG) configuration.load_server_configuration() base_init() if len(sys.argv) == 1: # No parameters passed servicemanager.Initialize() servicemanager.PrepareToHostSingle(Service) servicemanager.StartServiceCtrlDispatcher() else: if sys.argv[1] == 'test': configure_server()
if __name__ == "__main__": from koi.base_logging import init_logging from koi.Configurator import init_i18n, load_configuration, configuration init_logging("rlab.log") init_i18n() load_configuration() from koi.db_mapping import metadata from koi.datalayer.database_session import init_db_session init_db_session(configuration.database_url, metadata, False or configuration.echo_query) import os from docxtpl import DocxTemplate from koi.dao import dao from koi.server.json_decorator import JsonCallWrapper from koi.doc_manager.documents_service import DocumentsService from koi.doc_manager.client_utils import download_document from koi.reporting.utils import make_home_file from koi.portability import open_a_file_on_os from koi.translators import amount_to_s HORSE_REFERENCE = "order_confirmation_letter" HORSE_TEMPLATE = "order_confirmation_report.docx" HORSE_TITLE = _("Order confirmation template") def print_order_confirmation_report(order_id):
""" def dirup(path): return os.path.split(os.path.abspath(path))[0] updir = dirup(dirup(__file__)) # sys.path.append(updir) # sys.path.append(os.path.join(updir,'server')) # sys.path.append(os.path.join(updir,'datalayer')) from koi.Configurator import init_i18n, load_configuration, resource_dir from koi.base_logging import init_logging init_logging("test.log") init_i18n() # load_configuration(os.path.join( resource_dir,'test_config.cfg')) load_configuration('config.cfg') # load_configuration() # Default run on my PC from koi.Configurator import mainlog, configuration import koi.db_mapping from koi.datalayer.database_session import init_db_session, session init_db_session(configuration.database_url, koi.db_mapping.metadata, True or configuration.echo_query) from koi.db_mapping import *
""" Pay attention ! Tests are not a submodule of the project """ # def dirup(path): # return os.path.split(os.path.abspath(path))[0] # updir = dirup(dirup(__file__)) # sys.path.append(updir) # sys.path.append(os.path.join(updir,'server')) # sys.path.append(os.path.join(updir,'datalayer')) from koi.Configurator import init_i18n, load_configuration, resource_dir from koi.base_logging import init_logging, mainlog init_logging("test.log", hook_exceptions=False) mainlog.setLevel(logging.DEBUG) init_i18n() mainlog.debug(u"Test resource dir is {}".format(resource_dir)) load_configuration( os.path.abspath(os.path.join(resource_dir, 'test_config.cfg'))) from koi.Configurator import configuration import koi.db_mapping from koi.datalayer.database_session import init_db_session, session init_db_session(configuration.database_url, koi.db_mapping.metadata, False or configuration.echo_query) from koi.datalayer.create_database import create_all_tables, do_basic_inserts, drop_all_tables, set_up_database, disconnect_db, create_root_account from koi.datalayer.utils import _extract_db_params_from_url
import socket import os import glob import tempfile import zipfile import shutil from distutils.version import StrictVersion import re import configobj import logging from koi.base_logging import mainlog, init_logging, init_server_directory init_server_directory() mainlog.setLevel(logging.DEBUG) init_logging("admin.log") from koi.Configurator import init_i18n, load_configuration, resource_dir, configuration, get_data_dir from koi.legal import copyright_years, copyright, license_short init_i18n() try: load_configuration("server.cfg", "server_config_check.cfg") except: load_configuration(None, "server_config_check.cfg") from PySide.QtCore import Slot, Qt from PySide.QtGui import QPushButton, QVBoxLayout, QHBoxLayout, QWidget, QApplication, QMainWindow, QLabel, QFileDialog, QTextEdit, QLineEdit, QGridLayout from PySide.QtGui import QDialog, QDialogButtonBox, QMessageBox, QGroupBox
"The backup of was done correctly DB:{}, files: {} / {} bytes.". format(size_to_str(bytes), total_files, total_bytes), configuration) except Exception as ex: mainlog.error("Failed to complete backup") mainlog.exception(ex) send_mail("Backup FAILURE", "The backup of was *not* done correctly.", configuration) if __name__ == "__main__": from koi.base_logging import init_logging, mainlog import logging mainlog.setLevel(logging.DEBUG) init_logging("backup.log") from koi.Configurator import load_configuration, configuration, get_data_dir configuration.load_server_configuration() parser = argparse.ArgumentParser( description='Here are the command line arguments you can use :') parser.add_argument('--backup', action='store_true', default=False, help='Backup database and documents') parser.add_argument('--restore', action='store_true', default=False, help='Restore database and documents') args = parser.parse_args()
import argparse import cherrypy import re import zipfile from mediafire.client import MediaFireClient from koi.Configurator import init_i18n init_i18n('en_EN') # The server speaks english from koi.base_logging import mainlog, init_logging, get_data_dir from koi.as_unicorn import codename if __name__ == "__main__": init_logging("http.log", console_log=True) # mainlog.setLevel(logging.DEBUG) from koi.tools.chrono import * from koi.Configurator import configuration, resource_dir, configuration_file_exists, path_to_config, make_empty_configuration_file, load_configuration_server, guess_server_url from koi.server.net_tools import guess_server_public_ip from koi.legal import copyright, license_short from koi.dao import dao from koi.backup.pg_backup import full_restore from koi.server.demo import create_demo_database from koi.datalayer.create_database import create_root_account def base_init(): global services, json_rpc_dispatcher
clock_client_id = None if __name__ == "__main__": if len(sys.argv) > 1: clock_client_id = sys.argv[1] elif 'VNCDESKTOP' in os.environ: clock_client_id = os.environ['VNCDESKTOP'] else: print("Please provide a suitable clock delivery_slips ID") print( "It is either a command line parameter or the env. variable VNCDESKTOP" ) exit() from koi.base_logging import init_logging init_logging("clock_client_{}.log".format("_".join( clock_client_id.strip().split()))) from koi.Configurator import init_i18n, load_configuration load_configuration("server.cfg") init_i18n() from koi.Configurator import resource_dir from koi.tools.chrono import * from koi.server.MemoryLogger import MemLogger from koi.User import User from koi.Task import TaskSet from koi.db_mapping import TaskActionReportType
parser.add_argument('--finish-update', default=False, help='Continue the update process started by a previous instance') #parser.add_argument('--reinstall', action='store_true', default=False, help='Reinstall the version of the version server') parser.add_argument('--console', action='store_true', default=False, help='Activate console output') parser.add_argument('--debug', action='store_true', default=False, help='Verbose debug output output') parser.add_argument('--dev', action='store_true', default=False, help='Equals --console --debug --no-update') parser.add_argument('--demo', action='store_true', default=False, help='Run as the demo') parser.add_argument('--screenshots', action='store_true', default=False, help='Make a collection of screenshots') parser.add_argument('--echo-sql', action='store_true', default=False, help='Show SQL statements') parser.add_argument('--no-update', action='store_true', default=False, help='Run without trying to update') # parser.add_argument('--watchdog-file', action='store_true', default="watchdog", help='Watch dog file') args = parser.parse_args() if args.dev: args.debug = args.console = args.no_update = True init_logging( console_log=args.console) if args.debug: mainlog.setLevel(logging.DEBUG) mainlog.info(copyright()) mainlog.info(license_short()) if args.screenshots: init_i18n("en_UK") else: init_i18n() load_configuration() upgrade_process(args)
server = HTTPServer( ('', int(configuration.get("DownloadSite", "port"))), MyHandler) mainlog.info("Starting server on port {}".format( configuration.get("DownloadSite", "port"))) while keep_running(): server.handle_request() except KeyboardInterrupt: mainlog.info('^C received, shutting down server') server.socket.close() if __name__ == '__main__': from koi.base_logging import init_logging, mainlog, log_stacktrace init_logging("file_server.log") from koi.Configurator import load_configuration, init_i18n, configuration, resource_dir load_configuration("server.cfg", "server_config_check.cfg") frozen = getattr(sys, 'frozen', False) mainlog.info(len(sys.argv)) mainlog.info(frozen) if (not frozen and len(sys.argv) >= 2) or (frozen and len(sys.argv) >= 1): import pythoncom import win32serviceutil import win32service import win32event import servicemanager class AppServerSvc(win32serviceutil.ServiceFramework):
# if view: # view.setRowHidden( i, True) # return nr_matches,first_match @Slot(QModelIndex) def index_changed(ndx): # print "index_changed {}".format(ndx) pass if __name__ == "__main__": from koi.base_logging import init_logging from koi.Configurator import init_i18n, load_configuration init_logging("completer.log") init_i18n() load_configuration("config.cfg") from koi.Configurator import configuration # Why should I do this here ? I don't get it :-( from koi.datalayer.sqla_mapping_base import metadata from koi.datalayer.database_session import init_db_session init_db_session(configuration.database_url, metadata, False or configuration.echo_query) from PySide.QtGui import QApplication, QMainWindow, QWidget, QHBoxLayout from koi.dao import dao app = QApplication(sys.argv) window = QMainWindow()