def handle_error(self, errno, errmsg, headers):
     self.apploader.context.error_dialog(
         ImportError, "Applet code at URL %s not loaded (%s: %s)" %
         (self.apploader.codeurl, errno, errmsg))
     self.apploader.close()
     self.apploader = None
     BaseReader.handle_error(self, errno, errmsg, headers)
Exemplo n.º 2
0
 def handle_error(self, errno, errmsg, headers):
     self.apploader.context.error_dialog(
         ImportError,
         "Applet code at URL %s not loaded (%s: %s)" %
         (self.apploader.codeurl, errno, errmsg))
     self.apploader.close()
     self.apploader = None
     BaseReader.handle_error(self, errno, errmsg, headers)
Exemplo n.º 3
0
  def __init__(self, args):
    self.source = args['source']
    self.regex = re.compile(args['regex'])
    self.lastmatch = None

    BaseReader.__init__(self)
    self.log.info("Created Regex Website Reader with source %s" % self.source)
    self.checkUpdate()
Exemplo n.º 4
0
    def __init__(self, args):
        self.source = args["source"]
        # init data
        file = open(self.source, "rb")
        self.data = file.read()
        file.close()

        BaseReader.__init__(self)
        self.log.info("Starting File Reader with source", self.source)
Exemplo n.º 5
0
 def handle_error(self, errcode, errmsg, headers):
     if self.save_file:
         self.save_file.close()
         self.save_file = None
         if self.save_mailcap:
             try:
                 os.unlink(self.save_filename)
             except os.error:
                 pass
     BaseReader.handle_error(self, errcode, errmsg, headers)
Exemplo n.º 6
0
 def handle_error(self, errcode, errmsg, headers):
     if self.save_file:
         self.save_file.close()
         self.save_file = None
         if self.save_mailcap:
             try:
                 os.unlink(self.save_filename)
             except os.error:
                 pass
     BaseReader.handle_error(self, errcode, errmsg, headers)
Exemplo n.º 7
0
  def __init__(self, args):
    # The address of the xml feed
    self.source = args['source']
    # To store the parsed xml data
    self.data = None
    # A value to compare with to check whether the feed has updated
    # Currently is hash of latest item title
    self.latest = None

    BaseReader.__init__(self)
    self.log.info("Created Atom Reader with source %s" % self.source)
Exemplo n.º 8
0
  def __init__(self, args):
    self.regex = re.compile(self.ITEM_PATTERN, re.DOTALL)
    self.dataregex = re.compile(self.DATA_PATTERN, re.DOTALL | re.VERBOSE)
    self.datafreeregex = re.compile(self.DATA_FREE_PATTERN,
                                    re.DOTALL | re.VERBOSE)
    self.dataemptyregex = re.compile(self.DATA_EMPTY_PATTERN,
                                     re.DOTALL | re.VERBOSE)
    self.prevsales = None

    BaseReader.__init__(self)
    self.log.info("Created Steam Sale Reader")
Exemplo n.º 9
0
    def restart(self, url):
        self.maxrestarts = self.maxrestarts - 1

        self.viewer = self.last_context.viewer
        self.app = self.last_context.app

        self.parser = None

        tuple = urlparse.urlparse(url)
        # it's possible that the url send in a 301 or 302 error is a
        # relative URL.  if there's no scheme or netloc in the
        # returned tuple, try joining the URL with the previous URL
        # and retry parsing it.
        if not (tuple[0] and tuple[1]):
            url = urlparse.urljoin(self.url, url)
            tuple = urlparse.urlparse(url)
        self.url = url

        self.fragment = tuple[-1]
        tuple = tuple[:-1] + ("", )
        if self.user_passwd:
            netloc = tuple[1]
            i = string.find(netloc, '@')
            if i >= 0: netloc = netloc[i + 1:]
            netloc = self.user_passwd + '@' + netloc
            tuple = (tuple[0], netloc) + tuple[2:]
        realurl = urlparse.urlunparse(tuple)

        # Check first to see if the previous Context has any protocol handlers
        api = self.last_context.get_local_api(realurl, self.method,
                                              self.params)
        if not api:
            if self.app:
                api = self.app.open_url(realurl,
                                        self.method,
                                        self.params,
                                        self.reload,
                                        data=self.data)
            else:
                import protocols
                api = protocols.protocol_access(realurl,
                                                self.method,
                                                self.params,
                                                data=self.data)

        BaseReader.__init__(self, self.last_context, api)
Exemplo n.º 10
0
    def restart(self, url):
        self.maxrestarts = self.maxrestarts - 1

        self.viewer = self.last_context.viewer
        self.app = self.last_context.app

        self.parser = None

        tuple = urlparse.urlparse(url)
        # it's possible that the url send in a 301 or 302 error is a
        # relative URL.  if there's no scheme or netloc in the
        # returned tuple, try joining the URL with the previous URL
        # and retry parsing it.
        if not (tuple[0] and tuple[1]):
            url = urlparse.urljoin(self.url, url)
            tuple = urlparse.urlparse(url)
        self.url = url

        self.fragment = tuple[-1]
        tuple = tuple[:-1] + ("",)
        if self.user_passwd:
            netloc = tuple[1]
            i = string.find(netloc, '@')
            if i >= 0: netloc = netloc[i+1:]
            netloc = self.user_passwd + '@' + netloc
            tuple = (tuple[0], netloc) + tuple[2:]
        realurl = urlparse.urlunparse(tuple)

        # Check first to see if the previous Context has any protocol handlers
        api = self.last_context.get_local_api(realurl, self.method,
                                              self.params)
        if not api:
            if self.app:
                api = self.app.open_url(realurl,
                                        self.method, self.params, self.reload,
                                        data=self.data)
            else:
                import protocols
                api = protocols.protocol_access(realurl,
                                                self.method, self.params,
                                                data=self.data)

        BaseReader.__init__(self, self.last_context, api)
Exemplo n.º 11
0
  def __init__(self, args):
    self.server = args['server']
    self.email = args['email']
    if args['ssl']:
      self.imap = imaplib.IMAP4_SSL
    else:
      self.imap = imaplib.IMAP4
    self.password = getpass.getpass("Enter password for %s:" % self.email)

    imap = self.imap(self.server)
    try:
      imap.login(self.email, self.password)
      self.state = imap.select()
    except imaplib.IMAP4.error:
      raise Exception("Incorrect username/password for %s" % self.email)
    imap.logout()

    BaseReader.__init__(self)
    self.log.info("Created IMAP Reader for %s" % self.email)
Exemplo n.º 12
0
    def __init__(self, args):
        self.server = args["server"]
        self.account = args["account"]
        if args["ssl"]:
            self.pop3 = poplib.POP3_SSL
        else:
            self.pop3 = poplib.POP3
        self.data = None
        self.moredata = None
        self.identifier = None
        self.password = getpass.getpass("Enter password for %s:" % self.account)

        pop3 = self.pop3(self.server)
        pop3.user(self.account)
        try:
            pop3.pass_(self.password)
            self.state = pop3.stat()
        except poplib.error_proto:
            raise Exception("Incorrect username/password for %s" % self.account)
        finally:
            pop3.quit()

        BaseReader.__init__(self)
        self.log.log("Starting POP3 Reader for %s" % self.account)
Exemplo n.º 13
0
 def stop(self):
     BaseReader.stop(self)
     if self.parser:
         parser = self.parser
         self.parser = None
         parser.close()
Exemplo n.º 14
0
 def __init__(self, context, api, filename):
     self.filename = filename
     self.fp = None
     BaseReader.__init__(self, context, api)
Exemplo n.º 15
0
 def __str__(self):
   return "%s(%s)" % (BaseReader.__str__(self), self.source)
 def __init__(self, context, api, apploader):
     self.apploader = apploader
     BaseReader.__init__(self, context, api)
Exemplo n.º 17
0
 def stop(self):
     BaseReader.stop(self)
     if self.parser:
         parser = self.parser
         self.parser = None
         parser.close()
Exemplo n.º 18
0
 def __init__(self, context, api, filename):
     self.filename = filename
     self.fp = None
     BaseReader.__init__(self, context, api)
Exemplo n.º 19
0
 def __init__(self, context, api, apploader):
     self.apploader = apploader
     BaseReader.__init__(self, context, api)
Exemplo n.º 20
0
  def __init__(self, args):
    self.source = args['source']
    self.state = None

    BaseReader.__init__(self)
    self.log.info("Created Simple Website Reader with source %s" % self.source)
Exemplo n.º 21
0
 def __str__(self):
   return "%s(%s)" % (BaseReader.__str__(self), self.email)