Beispiel #1
0
def main():
    opt_parser = OptionParser()
    opt_parser.add_option("-c","--config",action="store",type="string",
                          dest="config",default="~/.articles.ini")
    (option,args) = opt_parser.parse_args()
    config_file = os.path.expanduser(option.config)
    if not os.path.exists(config_file):
        print("configure file does not exists : " + config_file)
        return -1
    config = configure.read(config_file)

    entries = bib2html.read_bibtex(config)
    output(entries)
Beispiel #2
0
def main():
    opt_parser = OptionParser()
    opt_parser.add_option("-c","--config",action="store",type="string",
            dest="config",default="~/.articles.ini",
            help="specify the configure file [default:~/.articles.ini]")
    opt_parser.add_option("-n","--no-cgi-server",action="store_true",dest="nocgi",
            help="only generate HTML file (CGI server does not stand)")
    opt_parser.add_option("-i","--install",action="store_true",dest="install",
            help="install attachments (CGI server does not stand)")
    opt_parser.add_option("-b","--getbib",action="store_true",dest="getbib",
            help="get bib infos for .pdf files whose bibtexkey is absent in .bib file")
    opt_parser.add_option("-d","--daemonize",action="store_true",dest="daemonize",
            help="stand CGI server as a daemon process (experimental)")
    (option,args) = opt_parser.parse_args()

    config_file = os.path.expanduser(option.config)
    if not os.path.exists(config_file):
        print("configure file does not exists : " + config_file)
        sys.exit(1)

    try:
        config = configure.read(config_file)
    except UserWarning as e:
        print("\nERROR : configure file is invalid.")
        print e
        sys.exit(1)

    if option.getbib:
        bibupdate.update(config,silent=False)
        return

    bib2html.generate(config)
    if option.install:
        copy_attachment(config)
        return

    pid_filename = "/tmp/articles.pid"
    log_filename = "server.log"
    if not option.nocgi:
        if option.daemonize and not os.path.exists(pid_filename):
            from daemon import DaemonContext
            from daemon.pidfile import PIDLockFile
            dc = DaemonContext(
                    pidfile = PIDLockFile(pid_filename),
                    stderr = open(log_filename,"w+"),
                    working_directory = os.getcwd(),
                )
            with dc:
                start_CGI_server(config)
        else:
            start_CGI_server(config)
Beispiel #3
0
def main():
    opt_parser = OptionParser()
    opt_parser.add_option("-c",
                          "--config",
                          action="store",
                          type="string",
                          dest="config",
                          default="~/.articles.ini")
    (option, args) = opt_parser.parse_args()
    config_file = os.path.expanduser(option.config)
    if not os.path.exists(config_file):
        print("configure file does not exists : " + config_file)
        return -1
    config = configure.read(config_file)

    entries = bib2html.read_bibtex(config)
    output(entries)