def node2html(node,destRoot,force=False): """ TODO: Analysefehler: wenn mehrere Dateien erzeugt werden, muss hier noch was geändert werden... """ outdir = os.path.join(destRoot,*node.getLocation()) outfile = os.path.join(outdir,node.getOutputFile()) #node.getOutputFile(): #outfile = os.path.join(node.getModule().getLocalPath(),\ # node.getOutputFile()) #outdir,leaf = os.path.split(outfile) if not os.path.exists(outdir): os.makedirs(outdir) updodate = False assert node.modified is not None, str(node) if not force: try: if os.path.getmtime(outfile) > node.modified: updodate = True except os.error: pass if updodate: console.info("%s : up to date" % outfile) else: console.progress("Writing %s ..." % outfile) #print asctime(localtime(node.modified))) html = node.render_html(request=None) open(outfile,"w").write(html) for child in node.getChildren(): node2html(child,destRoot,force)
def node2html(node, destRoot, force=False): """ TODO: Analysefehler: wenn mehrere Dateien erzeugt werden, muss hier noch was geändert werden... """ outdir = os.path.join(destRoot, *node.getLocation()) outfile = os.path.join(outdir, node.getOutputFile()) #node.getOutputFile(): #outfile = os.path.join(node.getModule().getLocalPath(),\ # node.getOutputFile()) #outdir,leaf = os.path.split(outfile) if not os.path.exists(outdir): os.makedirs(outdir) updodate = False assert node.modified is not None, str(node) if not force: try: if os.path.getmtime(outfile) > node.modified: updodate = True except os.error: pass if updodate: console.info("%s : up to date" % outfile) else: console.progress("Writing %s ..." % outfile) #print asctime(localtime(node.modified))) html = node.render_html(request=None) open(outfile, "w").write(html) for child in node.getChildren(): node2html(child, destRoot, force)
def main(argv): console.copyleft(name="Lino/makelc",years='2002-2005') parser = console.getOptionParser( usage="usage: %prog [options] DIR1 [DIR2 ...]", description="""\ where DIR1 DIR2... are the root directories to be processed. Subdirectories of these directories will automatically be processed. """) (options, args) = parser.parse_args(argv) if len(args) == 0: parser.print_help() return -1 collector = Collector() for DIR in args: collect_upper(DIR,collector) if len(collector) > 0: if console.confirm( \ "Okay to rename %d directories or files [Yn]?" % \ len(collector)): for (o,n) in collector.filenames: os.rename(o,n) console.info("%d files renamed" % \ len(collector.filenames)) for (o,n) in collector.dirnames: os.rename(o,n) console.info("%d directories renamed" % \ len(collector.dirnames))
def main(argv): console.copyleft(name="Lino/makelc", years='2002-2005') parser = console.getOptionParser( usage="usage: %prog [options] DIR1 [DIR2 ...]", description="""\ where DIR1 DIR2... are the root directories to be processed. Subdirectories of these directories will automatically be processed. """) (options, args) = parser.parse_args(argv) if len(args) == 0: parser.print_help() return -1 collector = Collector() for DIR in args: collect_upper(DIR, collector) if len(collector) > 0: if console.confirm( \ "Okay to rename %d directories or files [Yn]?" % \ len(collector)): for (o, n) in collector.filenames: os.rename(o, n) console.info("%d files renamed" % \ len(collector.filenames)) for (o, n) in collector.dirnames: os.rename(o, n) console.info("%d directories renamed" % \ len(collector.dirnames))
def main(argv): parser = OptionParser() parser.add_option("-v", "--verbose", help="display many messages", action="store_true", dest="verbose", default=True) parser.add_option("-s", "--skip-dbcheck", help="skip integrity check of foreign databases", action="store_true", dest="skipTest", default=False) parser.add_option("-p", "--port", help="alternate PORT where to listen" "(default is 8080)", action="store", dest="port", type="int", default=8080, ) (options, args) = parser.parse_args(argv) del args[0] demoDir = os.path.dirname(__file__) #center.start(verbose=options.verbose) #info = center.getSystemConsole().info from lino.ui.console import info, progress #progress = app.console.progress schema = Schema(big=False) schema.startup() schema.setLayout(sprlwidgets) serverRsc = ServerResource(wwwRoot) #sess = ConsoleSession() sess = center.createSession() if True: """ Shared tables are the same for each database """ info("Starting std.db...") conn = Connection(schema=schema) stddb = Database(langs="en de fr et", schema=schema, name="std", label="shared standard data") sharedTables = (Languages, Nations, PartnerTypes, Currencies, AuthorEventTypes, PublicationTypes, ProjectStati, Users) stddb.connect(conn,sharedTables) ## stddb.createTables() ## sess.use(stddb) ## from lino.schemas.sprl.data import std ## std.populate(sess,big=False) #sess.end() for dbi in dbinfos: if len(args) == 0 or dbi.name in args: info("Opening %s..." % dbi.name) db = Database( langs=dbi.langs, schema=schema, name=dbi.name, label=dbi.label) conn = Connection(filename=dbi.dbfile, schema=schema) db.update(stddb) db.connect(conn) ## sess.use(db) serverRsc.addDatabase(db, stylesheet="www.css") sess = center.startup(checkIntegrity=not options.skipTest) ## if not options.skipTest: ## db.checkIntegrity(sess) if True: sys.path.insert(0,demoDir) #for modName in ('vor', 'etc'): for modName in ('etc',): info("Opening %s..." % modName) mod = __import__(modName) # my_import(modName) #print "%s (%s)" % (modName,mod.label) conn = Connection(filename=modName+'.db', isTemporary=True, schema=schema) db = Database( langs='en de', schema=schema, name=modName, label=mod.label) db.startup(conn) db.createTables() sess.use(db) mod.populate(sess) serverRsc.addDatabase(db) ## , staticDirs = { ## 'files': os.path.join(demoDir,modName,'files'), ## 'images': os.path.join(demoDir,modName,'images'), ## #'thumbnails': os.path.join(demoDir,modName,'thumbnails') ## }) #db.flush() del sys.path[0] progress("Twisted Lino Server") progress(copyleft(year='2004',author='Luc Saffre')) from twisted.web import server from twisted.internet import reactor site = server.Site(serverRsc) site.requestFactory = MyRequest reactor.listenTCP(options.port, site) reactor.addSystemEventTrigger("before","shutdown", \ center.shutdown) progress("Serving on port %s." % options.port) progress("(Press Ctrl-C to stop serving)") reactor.run()