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
#!/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)
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)
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
def logger(self): """Object for recording what we do.""" if not hasattr(self, "_logger"): self._logger = Logging.get_logger("cdr-scheduler") return self._logger
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)