Пример #1
0
    interrupt_id = None
    if inv.getRequest().getMethod() == "POST":
        if inv.hasParameter("interrupt"):
            interrupt_id = inv.getLong("thread-id")
            Monad.getUtils()["imprt"](
                globals(),
                {
                    "db": ["HhDatum", "Site", "Supply", "set_read_write", "session"],
                    "utils": ["UserException", "HH", "form_date"],
                    "templater": ["render", "on_start_report", "get_report"],
                },
            )

        elif inv.hasParameter("run_shutdown"):
            shutdown_contract = Contract.getNonCoreContract("shutdown")
            shutdown_contract.callFunction("on_shut_down", [Monad.getContext()])
            source.appendChild(MonadMessage("Shut down successfully.").toXml(doc))

        elif inv.hasParameter("run_startup"):
            startup_contract = Contract.getNonCoreContract("startup")
            startup_contract.callFunction("on_start_up", [Monad.getContext()])
        elif inv.hasParameter("cancel_backend"):
            backend_pid = inv.getLong("backend_pid")
            con = Hiber.session().connection()
            stmt = con.createStatement()
            stmt.execute("select pg_terminate_backend(" + str(backend_pid) + ")")
            stmt.close()
            Hiber.commit()
            source.appendChild(MonadMessage("Cancelled backend.").toXml(doc))

    df = DecimalFormat("###,###,###,###,##0")
Пример #2
0
import collections
import pytz
import threading
import sys
import os
import os.path
import time
import datetime
import utils

Monad.getUtils()['impt'](globals(), 'db', 'utils', 'templater')

UserException = utils.UserException

if sys.platform.startswith('java'):
    download_path = Monad.getContext().getRealPath("/downloads")
else:
    import chellow
    download_path = os.path.join(chellow.app.instance_path, 'downloads')

if not os.path.exists(download_path):
    os.makedirs(download_path)


download_id = 0

lock = threading.Lock()

files = sorted(os.listdir(download_path), reverse=True)
if len(files) > 0:
    download_id = int(files[0][:3]) + 1
Пример #3
0
        files.append(
            {
                'name': fl,
                'last_modified': datetime.datetime.utcfromtimestamp(
                    statinfo.st_mtime),
                'size': statinfo.st_size,
                'creation_date': datetime.datetime.utcfromtimestamp(
                    statinfo.st_ctime)})
    mem_items = dloads.get_mem_items()
    mem_keys = sorted(mem_items.keys())
    return {
        'files': files, 'messages': messages, 'mem_items': mem_items,
        'mem_keys': mem_keys}

try:
    lib_path = Monad.getContext().getRealPath("/WEB-INF/lib-python")
    if inv.getRequest().getMethod() == 'GET':
        templater.render(inv, template, make_fields(lib_path))
    else:
        if inv.hasParameter("delete"):
            name = inv.getString("name")
            shutil.rmtree(os.path.join(lib_path, name))
            inv.sendSeeOther("/reports/103/output/")
        else:
            file_item = inv.getFileItem("import_file")
            stream = file_item.getInputStream()
            f = StringIO.StringIO()
            bt = stream.read()
            while bt != -1:
                f.write(chr(bt))
                bt = stream.read()
Пример #4
0
def get_lib(lib_name):
    return Monad.getContext().getAttribute("net.sf.chellow." + lib_name)