Exemplo n.º 1
0
 def __init__(self, directory, user):
     self.chump = DailyChump(directory)
     self.user = user
Exemplo n.º 2
0
def main():
    import sys
    import getopt
    args = sys.argv[1:]
    optlist, args = getopt.getopt(args, 's:p:c:n:d:e:ha:vqiruw:x:', [
        "server=", "port=", "channel=", "nick=", "dir=", "stylesheet=", "help",
        "password="******"version", "quiet", "private", "address", "utf-8", "web",
        "xsl", "pingurl=", "formchatport=", "jabber-id=", "jabber-server=",
        "jabber-password="******"Error: Erroneous web port."
                sys.exit(1)
        elif name in ('-p', '--port'):
            try:
                port = int(value)
            except ValueError:
                print "Error: Erroneous port."
                sys.exit(1)
        elif name in ('-c', '--channel'):
            channel = value
        elif name in ('-n', '--nick'):
            nickname = value
        elif name in ('-d', '--dir'):
            directory = value
        elif name in ('-e', '--stylesheet'):
            sheet = value
        elif name in ('-a', '--password'):
            password = value
        elif name in ('-i', '--private'):
            mode = _M_PRIVMSG
        elif name in ('-q', '--quiet'):
            mode = _M_QUIET
        elif name in ('-r', '--address'):
            addressing = _A_SPECIFIC
        elif name in ('-u', '--utf-8'):
            use_unicode = 1
        elif name in ('-h', '--help'):
            usage(sys.argv[0])
            sys.exit(0)
        elif name in ('-v', '--version'):
            version()
            sys.exit(0)
        elif name in ('--pingurl'):
            pingurls.append(value)
        elif name in ('--formchatport'):
            formchatport = int(value)
        elif name in ('--jabber-server'):
            jabber_server = value
        elif name in ('--jabber-id'):
            jabber_id = value
        elif name in ('--jabber-password'):
            jabber_password = value

    from dailychumptwist import DailyChumpTwistFactory, DailyChumpTwist
    if (directory != '' and channel != '' and nickname != '' and server != ''):
        chump = DailyChump(directory, use_unicode)
        bot = DailyChumpTwistFactory(chump, channel, nickname, sheet, password,
                                     mode, addressing, use_unicode)
        app = service.Application("chump")
        servcoll = service.IServiceCollection(app)
        internet.TCPClient(server, port, bot).setServiceParent(servcoll)
        if len(pingurls) > 0:
            chump.add_listener(URLPinger(servcoll, pingurls))

        if formchatport is not None:
            g = TellChannelSite(chump)
            reactor.listenTCP(formchatport, g)

        if web_port is not None and xsldir is not None:
            try:
                import web
                web.xsldir = xsldir
                web.chumproot = directory
                import quixote.server.twisted_http
                quixote.server.twisted_http.Server("web", web_port)
            except ImportError:
                print "quixote not found, can't start web server"

        service.IService(app).startService()
        if jabber_password is not None and jabber_id is not None and jabber_server is not None:
            TwitterInterface(reactor, chump, jabber_id, jabber_password,
                             jabber_server)

        reactor.run()

    else:
        usage(sys.argv[0])
        sys.exit(1)
Exemplo n.º 3
0
import BaseHTTPServer
import re
import urllib
import string
from xml.xslt.Processor import Processor
from dailychump import DailyChump

BaseClass = BaseHTTPServer.BaseHTTPRequestHandler
chump = DailyChump("/tmp")


# code from
# http://www.faqts.com/knowledge_base/view.phtml/aid/4373
def urlParse(url):
    """ return path as list and query string as dictionary
        strip / from path
        ignore empty values in query string
        for example:
            if url is: /xyz?a1=&a2=0%3A1
            then result is: (['xyz'], { 'a2' : '0:1' } )
            if url is: /a/b/c/
            then result is: (['a', 'b', 'c'], None )
            if url is: /?
            then result is: ([], {} )
    """
    print "Parsing: " + url
    #x = string.split(url, '?')
    query_split = re.compile("([^?]*)\?(.*)")
    var_split = re.compile("([^=]*)=(.*)")
    match = query_split.match(url)
    if match != None: