コード例 #1
0
ファイル: static.py プロジェクト: MaxTyutyunnikov/lino
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) 
コード例 #2
0
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)
コード例 #3
0
ファイル: html2oo.py プロジェクト: MaxTyutyunnikov/lino
def main(argv):
    console.copyleft(name="Lino/html2sxc", years='2005')
    parser = console.getOptionParser(
        usage="usage: %prog [options] HTMLFILE",
        description="""\
where HTMLFILE is a html document containg tables
""" )
    
    parser.add_option("-o", "--output",
                      help="""\
generate to OUTFILE instead of default name. Default output filename
is HTMLFILE with extension .sxc depending on content.
""",
                      action="store",
                      type="string",
                      dest="outFile",
                      default=None)
    
    (options, args) = parser.parse_args(argv)

    if len(args) != 1:
        parser.print_help() 
        sys.exit(-1)
    ifname = args[0]
    print ifname
    (basename,ext) = os.path.splitext(ifname)
    console.progress("Processing " +ifname+" ...")
    doc = Document(basename+".sxc")

    w = formatter.NullWriter()
    fmt = formatter.AbstractFormatter(w)
    parser = MyParser(fmt)
    parser.feed(open(ifname).read())
    parser.close()
    for t in parser._tablesFound:
        dt = doc.table()
        for r in t:
            dt.addRow(*r)
    g=doc.generator(filename=options.outFile)
    g.save()
    if sys.platform == "win32" and console.isInteractive():
        os.system("start %s" % g.outputFilename)
コード例 #4
0
def main(argv):
    console.copyleft(name="Lino/html2sxc", years='2005')
    parser = console.getOptionParser(usage="usage: %prog [options] HTMLFILE",
                                     description="""\
where HTMLFILE is a html document containg tables
""")

    parser.add_option("-o",
                      "--output",
                      help="""\
generate to OUTFILE instead of default name. Default output filename
is HTMLFILE with extension .sxc depending on content.
""",
                      action="store",
                      type="string",
                      dest="outFile",
                      default=None)

    (options, args) = parser.parse_args(argv)

    if len(args) != 1:
        parser.print_help()
        sys.exit(-1)
    ifname = args[0]
    print ifname
    (basename, ext) = os.path.splitext(ifname)
    console.progress("Processing " + ifname + " ...")
    doc = Document(basename + ".sxc")

    w = formatter.NullWriter()
    fmt = formatter.AbstractFormatter(w)
    parser = MyParser(fmt)
    parser.feed(open(ifname).read())
    parser.close()
    for t in parser._tablesFound:
        dt = doc.table()
        for r in t:
            dt.addRow(*r)
    g = doc.generator(filename=options.outFile)
    g.save()
    if sys.platform == "win32" and console.isInteractive():
        os.system("start %s" % g.outputFilename)
コード例 #5
0
ファイル: lsaffre.py プロジェクト: BackupTheBerlios/lino-svn
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()