コード例 #1
0
ファイル: dictionary_loader.py プロジェクト: NCIOCPL/cdr-lib
    def logger(self):
        """Tool for recording what we do."""

        if not hasattr(self, "_logger"):
            opts = dict(level=self.loglevel)
            self._logger = Logging.get_logger(self.LOGNAME, **opts)
        return self._logger
コード例 #2
0
ファイル: Publish.py プロジェクト: NCIOCPL/cdr-publishing
#!/usr/bin/env python
"""Bridge PublishingService.py to cdrpub.py.
"""

from argparse import ArgumentParser
from cdr import Logging
from cdrpub import Control

parser = ArgumentParser()
parser.add_argument("job", type=int)
opts = parser.parse_args()
logger = Logging.get_logger("publish")
logger.info("Job %d started", opts.job)
try:
    Control(opts.job).publish()
    logger.info("Job %d ended", opts.job)
except Exception:
    logger.exception("Job %d failed", opts.job)
コード例 #3
0
These are values used by ElasticSearch index loaders. The values will be
in files contained in a single directory (typically Database/Loader from
a branch of the cdr-server GitHub repository).
"""

from argparse import ArgumentParser
from json import load, dumps
from pathlib import Path
from cdrapi import db
from cdr import getpw, login, updateCtl, Logging

ACCOUNT = "ReleaseInstaller"
EXTENSIONS = "json", "txt"

logger = Logging.get_logger("deploy", console=True)
parser = ArgumentParser()
parser.add_argument("--directory", "-d", required=True)
parser.add_argument("--tier", "-t")
parser.add_argument("--session", "-s")
parser.add_argument("--group", "-g")
parser.add_argument("--name", "-n")
parser.add_argument("--verbose", "-v", action="store_true")
opts = parser.parse_args()
logger.info("installing from %s", opts.directory)
try:
    if opts.session:
        session = opts.session
    else:
        password = getpw(ACCOUNT)
        session = login(ACCOUNT, password)
コード例 #4
0
mode to what it was before performing this task.

It hasn't been necessary to use simple recovery mode since May 2018,
when we had 866,772 versions to archive. If this is done at least once
a year, we'll never get near that number again.

https://collaborate.nci.nih.gov/display/OCECTBWIKI/CDR+Version+XML+Archive+Database
"""

from argparse import ArgumentParser
from datetime import datetime
from time import sleep
from cdrapi import db
from cdr import Logging

logger = Logging.get_logger("version-archiver")
parser = ArgumentParser()
parser.add_argument("--batch-size", type=int, default=100)
parser.add_argument("--max-batches", type=int, default=100000)
parser.add_argument("--tier")
opts = parser.parse_args()
try:
    conn = db.connect(tier=opts.tier)
    cursor = conn.cursor()
except:
    logger.exception("unable to connect to database")
    raise
cursor.execute("""\
SELECT MIN(v.dt) AS cutoff
  FROM CDR..all_doc_versions v
  JOIN cdr_archived_versions..doc_version_xml a
コード例 #5
0
    def logger(self):
        """Object for recording what we do."""

        if not hasattr(self, "_logger"):
            self._logger = Logging.get_logger("cdr-scheduler")
        return self._logger
コード例 #6
0
cols = "d.id", "t.name", "ISNULL(l.value, 'English') AS language"
query = db.Query("document d", *cols)
query.join("doc_type t", "t.id = d.doc_type")
query.join("pub_proc_cg c", "c.id = d.id")
query.outer("query_term l", "l.doc_id = d.id", f"path = '{PATH}'")
if opts.cis:
    query.where("t.name = 'Summary'")
elif opts.dis:
    query.where("t.name = 'DrugInformationSummary'")
else:
    query.where("t.name in ('Summary', 'DrugInformationSummary')")
query.order(3, "d.id")
if opts.verbose:
    print(query)
rows = query.execute(session.cursor).fetchall()
if opts.verbose:
    print(f"{len(rows)} found by query")
end = min(opts.skip + opts.max, len(rows))
rows = rows[opts.skip:end]
if opts.verbose:
    print(f"sending {len(rows)} docs ({opts.skip+1} - {end})")
docs = dict([(row.id, row.name) for row in rows])
opts = dict(
    send=docs,
    base=opts.base,
    dumpfile=opts.dumpfile,
    auth=auth,
    logger=Logging.get_logger("populate-drupal-cms", level=opts.level),
)
Control.update_cms(session, **opts)