def init_and_get_task(args): conn = TypesDatabase.open_db(args.db) TypesDatabase.create_if_needed(conn) task = Task() if args.recalc: find_all(conn, args, task) else: find_missing(conn, args, task) conn.commit() task.prepare() return task
def get_args(): parser = optparse.OptionParser( description='Initialise the database and calculate all statistics.', version=TypesDatabase.version_string(TOOL), ) parser.add_option('--db', metavar='FILE', dest='db', help='which database to read [default: %default]', default=TypesDatabase.DEFAULT_FILENAME) TypesParallel.add_options(parser) parser.add_option('--dry-run', dest='dryrun', action='store_true', help='initialise the database if needed, but do not run calculation; just tell what would happen', default=False) parser.add_option('--recalc', dest='recalc', action='store_true', help='recalculate even if results already exist', default=False) parser.add_option('--conly', dest='p', action='store_false', help='only curves [default: curves and permutation testing]', default=True) parser.add_option('--ponly', dest='c', action='store_false', help='only permutation testing', default=True) parser.add_option('--citer', metavar='N', dest='citer', type=int, help='number of iterations for curves [default: %default]', default=CITER) parser.add_option('--piter', metavar='N', dest='piter', type=int, help='number of iterations for permutation testing [default: %default]', default=PITER) parser.add_option('--x', metavar='N', dest='x', help='maximum x resolution (number of slots) [default: %default]', default=X_DEF) parser.add_option('--y', metavar='N', dest='y', help='maximum y resolution (number of slots) [default: %default]', default=Y_DEF) (options, args) = parser.parse_args() return options
def main(): args = get_args() if not os.path.exists(args.tmpdir): os.makedirs(args.tmpdir) conn = TypesDatabase.open_db(args.db) ac = AllCurves() ac.read_curves(args, conn) conn.commit() if len(ac.curves) == 0: msg('there are no results in the database') return ac.create_directories() sys.stderr.write('%s: write: (' % TOOL) ac.generate_index(args.htmldir) if ac.with_lists: ac.generate_context(args.htmldir) ac.generate_html() sys.stderr.write(')\n') redraw = ac.find_outdated() nredraw = len(redraw) if nredraw == 0: msg('all files up to date') else: msg('outdated: %d files' % nredraw) write_data(args, redraw) run(args, nredraw) os.remove(get_datafile(args)) msg('all done')
def get_args(): parser = optparse.OptionParser( description='Update all plots.', version=TypesDatabase.version_string(TOOL), ) parser.add_option('--db', metavar='FILE', dest='db', help='which database to read [default: %default]', default=TypesDatabase.DEFAULT_FILENAME) TypesParallel.add_options(parser) parser.add_option('--type-lists', dest='with_typelists', action='store_true', help='produce type lists', default=False) parser.add_option('--sample-lists', dest='with_samplelists', action='store_true', help='produce sample lists', default=False) parser.add_option('--slides', dest='slide_version', action='store_true', help='presentation slide version', default=False) parser.add_option('--plotdir', metavar='DIRECTORY', dest='plotdir', help='where to store PDF plots [default: %default]', default=PLOT_DIR) parser.add_option('--htmldir', metavar='DIRECTORY', dest='htmldir', help='where to store SVG plots and HTML files [default: %default]', default=HTML_DIR) (options, args) = parser.parse_args() return options
def main(): args = get_args() conn = TypesDatabase.open_db(args.db) data = {} s = args.srcdir d = args.destdir if not os.path.exists(d): print d os.makedirs(d) for fn in os.listdir(s): if fn.startswith('.'): continue print fn shutil.copy2(os.path.join(s, fn), os.path.join(d, fn)) for w in what: dump(data, conn, *w) fn = "types-data.js" print(fn) jsfile = os.path.join(d, fn) with open(jsfile, "w") as f: f.write('types.data(') f.write(json.dumps(data, sort_keys=True, separators=(',', ':'))) f.write(')')
def get_args(): parser = optparse.OptionParser( description='Generate web user interface.', version=TypesDatabase.version_string(TOOL), ) parser.add_option('--db', metavar='FILE', dest='db', help='which database to read [default: %default]', default=TypesDatabase.DEFAULT_FILENAME) parser.add_option('--srcdir', metavar='FILE', dest='srcdir', help='HTML source directory [default: %default]', default=DEFAULT_SRC) parser.add_option('--destdir', metavar='FILE', dest='destdir', help='HTML targer directory [default: %default]', default=DEFAULT_DEST) (options, args) = parser.parse_args() return options
def get_args(): parser = optparse.OptionParser( description='Update all plots.', version=TypesDatabase.version_string(TOOL), ) parser.add_option('--db', metavar='FILE', dest='db', help='which database to read [default: %default]', default=TypesDatabase.DEFAULT_FILENAME) TypesParallel.add_options(parser) parser.add_option('--plotdir', metavar='DIRECTORY', dest='plotdir', help='where to store PDF plots [default: %default]', default=PLOT_DIR) parser.add_option('--htmldir', metavar='DIRECTORY', dest='htmldir', help='where to store SVG plots and HTML files [default: %default]', default=HTML_DIR) (options, args) = parser.parse_args() return options
def get_args(): parser = optparse.OptionParser( description='Update all plots.', version=TypesDatabase.version_string(TOOL), ) parser.add_option('--db', metavar='FILE', dest='db', help='which database to read [default: %default]', default=TypesDatabase.DEFAULT_FILENAME) TypesParallel.add_options(parser) parser.add_option('--type-lists', dest='with_typelists', action='store_true', help='produce type lists', default=False) parser.add_option('--sample-lists', dest='with_samplelists', action='store_true', help='produce sample lists', default=False) parser.add_option('--slides', dest='slide_version', action='store_true', help='presentation slide version', default=False) parser.add_option('--plotdir', metavar='DIRECTORY', dest='plotdir', help='where to store PDF plots [default: %default]', default=PLOT_DIR) parser.add_option( '--htmldir', metavar='DIRECTORY', dest='htmldir', help='where to store SVG plots and HTML files [default: %default]', default=HTML_DIR) (options, args) = parser.parse_args() return options
def postprocess(args): conn = TypesDatabase.open_db(args.db) TypesDatabase.refresh_result(conn) conn.commit()
def db_init(filename=TypesDatabase.DEFAULT_FILENAME): conn = TypesDatabase.open_db(filename) TypesDatabase.drop_views(conn) TypesDatabase.create_if_needed(conn) TypesDatabase.refresh_result(conn) conn.commit()
def db_init(filename=TypesDatabase.DEFAULT_FILENAME): conn = TypesDatabase.open_db(filename) TypesDatabase.create_if_needed(conn) conn.commit()