Пример #1
0
def main(argv=None):
    if argv is None:
        argv = sys.argv
    try:
        try:
            opts, args = getopt.getopt(
                argv[1:], "hrid",
                ["help", "report", "install-new", "remove-old"])
        except getopt.error, msg:
            raise UsageError(msg)

        if len(args) > 0:  # have arguments
            raise UsageError('E: Wrong number of argument.')

        if len(opts) == 0:  # empty... no options
            raise UsageError(usage)

        #LOGIC STARTS HERE
        enable_ptl()

        for opt, arg in opts:
            if opt in ('-h', '--help'):
                raise UsageError(usage)
            elif opt in ('-r', '--report'):
                UrlSpider(ROOT_NAMESPACE, APP_ROOT, IGNORE_NEW_URLS,
                          IGNORE_OLD_URLS).report()
            elif opt in ('-i', '--install-new'):
                UrlSpider(ROOT_NAMESPACE, APP_ROOT, IGNORE_NEW_URLS,
                          IGNORE_OLD_URLS).install_new_urls()
            elif opt in ('-d', '--remove-old'):
                UrlSpider(ROOT_NAMESPACE, APP_ROOT, IGNORE_NEW_URLS,
                          IGNORE_OLD_URLS).remove_old_urls()
Пример #2
0
def get_publisher():
    quixote.enable_ptl()
    from lap.web.site import root
    if DEBUG:
        config = Config(display_exceptions='html')
    else:
        config = None
    return DatabasePublisher(root.index(), config)
Пример #3
0
    def __init__(self, approot, config_file=None, port=80,
	       enable_ptl=True, publisher=Publisher):
	self.approot = approot
	self.config_file = config_file
	self.port = port
	self.publishclass = publisher
	if enable_ptl:
	    from quixote import enable_ptl
	    enable_ptl()
Пример #4
0
    def __init__(self, approot, create_publisher, config_file=None, port=80,
	       enable_ptl=True):
	self.approot = approot
	self.config_file = config_file
	self.port = port
	#self.publishclass = publisher
	self.publisher = create_publisher()
	if enable_ptl:
	    from quixote import enable_ptl
	    enable_ptl()
Пример #5
0
def main():
    from quixote import enable_ptl
    enable_ptl()

    if len(sys.argv) == 2:
        port = int(sys.argv[1])
    else:
        port = 8080
    print 'Now serving the Quixote demo on port %d' % port
    server = http_server.http_server('', port)
    publisher = Publisher('quixote.demo')

    # When initializing the Publisher in your own driver script,
    # you'll want to parse a configuration file.
    ##publisher.read_config("/full/path/to/demo.conf")
    publisher.setup_logs()
    dh = QuixoteHandler(publisher, 'Quixote/demo', server)
    server.install_handler(dh)
    asyncore.loop()
Пример #6
0
def main():
    from quixote import enable_ptl
    enable_ptl()

    if len(sys.argv) == 2:
        port = int(sys.argv[1])
    else:
        port = 8080
    print 'Now serving the Quixote demo on port %d' % port
    server = http_server.http_server('', port)
    publisher = Publisher('quixote.demo')

    # When initializing the Publisher in your own driver script,
    # you'll want to parse a configuration file.
    ##publisher.read_config("/full/path/to/demo.conf")
    publisher.setup_logs()
    dh = QuixoteHandler(publisher, 'Quixote/demo', server)
    server.install_handler(dh)
    asyncore.loop()
Пример #7
0
#
# <Location "^/qdemo/">
#       SCGIServer 127.0.0.1 4000
#       SCGIHandler On
# </Location>


from scgi.quixote_handler import QuixoteHandler, main
from quixote import enable_ptl, Publisher

class DemoPublisher(Publisher):
    def __init__(self, *args, **kwargs):
        Publisher.__init__(self, *args, **kwargs)

        # (Optional step) Read a configuration file
        self.read_config("demo.conf")

        # Open the configured log files
        self.setup_logs()


class DemoHandler(QuixoteHandler):
    publisher_class = DemoPublisher
    root_namespace = "quixote.demo"
    prefix = "/qdemo"


# Install the import hook that enables PTL modules.
enable_ptl()
main(DemoHandler)
Пример #8
0
        for f in files:
            self.files[os.path.abspath(f)] = 1

        if otherConfigFiles is None:
            otherConfigFiles = []
        for arg, value in args:
            shortArg, useValue, longArg, member, description = _OPTIONS_DICT[
                arg]
            if member == None:
                # FIXME: this whole block is a hack
                if longArg == 'rcfile':
                    sys.stdout.write(outputRc(self))
                    continue
                elif longArg == 'quixote':
                    import quixote
                    quixote.enable_ptl()
                    self.quixote = 1
                    continue
                elif longArg == 'config':
                    otherConfigFiles.append(value)
                    continue
                elif longArg == 'version':
                    # FIXME: it would be nice to define this in only one place
                    print _VERSION
                    sys.exit(0)
                elif longArg == 'level':
                    normalizedValue = value.capitalize()
                    if not _WARNING_LEVELS.has_key(normalizedValue):
                        sys.stderr.write('Invalid warning level (%s).  '
                                         'Must be one of: %s\n' %
                                         (value, _WARNING_LEVELS.keys()))
Пример #9
0
 def __init__(self, *args, **kwargs):
     enable_ptl()
     QuixoteHandler.__init__(self, *args, **kwargs)
Пример #10
0
        for f in files:
            self.files[os.path.abspath(f)] = 1

        if otherConfigFiles is None:
            otherConfigFiles = []
        for arg, value in args:
            shortArg, useValue, longArg, member, description = _OPTIONS_DICT[arg]
            if member == None:
                # FIXME: this whole block is a hack
                if longArg == "rcfile":
                    sys.stdout.write(outputRc(self))
                    continue
                elif longArg == "quixote":
                    import quixote

                    quixote.enable_ptl()
                    self.quixote = 1
                    continue
                elif longArg == "config":
                    otherConfigFiles.append(value)
                    continue
                elif longArg == "version":
                    # FIXME: it would be nice to define this in only one place
                    print _VERSION
                    sys.exit(0)
                elif longArg == "level":
                    normalizedValue = value.capitalize()
                    if not _WARNING_LEVELS.has_key(normalizedValue):
                        sys.stderr.write(
                            "Invalid warning level (%s).  " "Must be one of: %s\n" % (value, _WARNING_LEVELS.keys())
                        )
Пример #11
0
 def __init__(self, *args, **kwargs):
     enable_ptl()
     QuixoteHandler.__init__(self, *args, **kwargs)