Skip to content
Snippets Groups Projects
  1. Mar 11, 2014
    • W. Trevor King's avatar
      irkerd: Replace Exception.format_exc() with traceback.format_exc() · 19f7fd76
      W. Trevor King authored
      The former was giving me:
      
        Traceback (most recent call last):
          File "/usr/lib64/python3.3/threading.py", line 901, in _bootstrap_inner
            self.run()
          File "/usr/lib64/python3.3/threading.py", line 858, in run
            self._target(*self._args, **self._kwargs)
          File "./irkerd", line 637, in dequeue
            LOG.debug(e.format_exc())
        AttributeError: 'TypeError' object has no attribute 'format_exc'
      
      In Python 3.3.4.
      19f7fd76
    • W. Trevor King's avatar
      irkerd: Add Python-3-compatible string handling · e29c46a9
      W. Trevor King authored
      This implements the necessary changes to work around the (str,
      unicode) -> (bytes, str) transition.  We decode the bytes as soon as
      possible after receiving them in the Irker*Handler classes.  For
      IRC-side connections, we still encode outgoing data right before
      sending it in IRCServerConnection.ship.
      
      We decode incoming IRC-side bytes in IRCServerConnection.consume,
      after storing them as bytes in the LineBufferedStream
      IRCServerConnection.buffer.  That ensures that we don't try and decode
      partial code points which are split across two socket messages.
      e29c46a9
    • W. Trevor King's avatar
      irkerd: Use self instead of LineBufferedStream in lines() · 86cd0f2e
      W. Trevor King authored
      That's what 'self' is for ;).  Also prefix 'crlf_re' with an
      underscore to mark it as private data, and not part of
      LineBufferedStream's API.
      86cd0f2e
    • W. Trevor King's avatar
      irkerd: Add Python-3-compatible import names · 4b327080
      W. Trevor King authored
      Prefer the Python 3 names to the Python 2 names for forward
      compatibility.
      4b327080
    • W. Trevor King's avatar
      irkerd: Drop scheme replacement in Target.__init__ · 9e1147e9
      W. Trevor King authored
      Now that we've dropped support for Python 2.5, we don't need this
      workaround anymore.
      9e1147e9
    • W. Trevor King's avatar
      irkerd: Drop simplejson replacement · cc44ada0
      W. Trevor King authored
      Since we no longer officially support Python 2.5, there's no *need* to
      use a fallback JSON library.  Removing it makes our dependencies
      cleaner, and JSON-parsing speed is not likely to be a large fraction
      of irkerd cycles anyway.
      cc44ada0
    • W. Trevor King's avatar
      irkerd: Convert to Python 3's "except x as y" syntax · 893598d2
      W. Trevor King authored
      Support for this was added in Python 2.6 and 3.0.  We can't have
      Python 3 compatibility without removing the old "except x, y" syntax,
      and I think 3.x support is more imporant than 2.5 support.  In any
      case, the existing irkerd has been using the new syntax since 3cc87513
      (Truncate messages that are longer than 512 bytes and catch any
      exceptions irclib throws about rejected messages, 2013-01-21), so this
      commit is not a *new* break with 2.5 support.
      893598d2
    • W. Trevor King's avatar
      irkerd: Replace sys.stderr.write with LOG.error · 602989fd
      W. Trevor King authored
      Thie makes logging more consistent with other errors (e.g. you can
      adjust the logging Handler and get all the errors sent to syslog or a
      file).  I also removed the 'irkerd: ' prefix; if we want that, I think
      we should add it to all logged messages by using a custom string in
      the logging Formatter.
      602989fd
    • W. Trevor King's avatar
      irkerd: Replace a print statement with LOG.error · 84ca40b2
      W. Trevor King authored
      Print statements are gone in Python 3, so this removes a barrier to
      Python 3 support.  It also makes the logging more consistent with
      other errors (e.g. the StreamHandler will print it to stdout, while
      the print statement was sending it to stderr).
      84ca40b2
    • W. Trevor King's avatar
      irkerd: Transition from getopt to argparse · ccd311c5
      W. Trevor King authored
      This gives us long options and removes the need to code our own usage
      string and choice-base argument processing.  I also removed the blurb
      about options from the module docstring, to avoid duplicating
      information.
      ccd311c5
    • W. Trevor King's avatar
      irkerd: Replace 'password' global with local Connection.password · f52ae77d
      W. Trevor King authored
      Using the new kwargs handling to pass the data through Irker() down to
      Connection().  Note that this is the nickserv password, not the
      server-wide login password used by Connection.connect().
      f52ae77d
    • W. Trevor King's avatar
    • W. Trevor King's avatar
      irkerd: Replace 'namestyle' global with local 'nick_template' · 8c2e9ccb
      W. Trevor King authored
      Using the new kwargs handling to pass the data through Irker() down to
      Connection().  I think 'nick_template' more clearly reflects
      the contents of this variable.
      8c2e9ccb
    • W. Trevor King's avatar
      irkerd: Replace 'fallback' global with local 'nick_needs_number' · 95f9109d
      W. Trevor King authored
      Using the new kwargs handling to pass the data through Irker() down to
      Connection().
      95f9109d
    • W. Trevor King's avatar
      irkerd: Add kwargs handling to pass data to IRCServerConnection.connect · 094d3470
      W. Trevor King authored
      This makes it easy to pass data down the stack:
      
        Irker() (stored in Irker.kwargs)
        `-- Irker.handle() -> Dispatcher() (stored in Dispatcher.kwargs)
            `-- Dispatcher.dispatch() -> Connection() (stored in Connection.kwargs)
                `-- Connection.dequeue() -> IRCServerConnection.connect()
      
      You can easily add data at every point in the stack (e.g. we add
      'target' in Irker.handle()) and pull it back out when that's
      appropriate (e.g. we tap 'target' back out in Connection()).  With
      this setup we can reduce the number of global variables currently in
      use, because it will be easy to pass data like passwords,
      nickame-fallback-ness, etc. down to the appropriate level, without the
      intermediate levels needing any changes.
      094d3470
    • W. Trevor King's avatar
      irkerd: Add Target.__str__ for pretty-printing targets in log messages · dde3c700
      W. Trevor King authored
      Prefer the servername, falling back to the URL, falling back to
      Target.__repr__().
      dde3c700
    • W. Trevor King's avatar
      irkerd: Convert to Python's logging module · 0a23831b
      W. Trevor King authored
      Instead of using the local IRCClient.debug() method, use the more
      flexible standard library logger.  This makes it easy to log to
      syslog, rotating files, etc, using the usual logging Handlers.  The
      mapping from the old implementation to the new implementation is:
      
        IRCClient.debug(1, message)  -> LOG.info(message)
        IRCClient.debug(2, message)  -> LOG.debug(message)
        IRCClient.debug(50, message) -> LOG.debug(message)
        Irker.logerr(errmsg)         -> LOG.error(message)
      
      with the exception of the failed-message error, which is logged as
      LOG.warning().  I didn't try and recategorize the other message log
      levels, although I think a number of info-level log messages should
      really be debug-level log messages.
      
      To set the log level, the -d option now takes string arguments
      (e.g. 'info', 'debug') instead of numeric arguments (e.g. '1', '2').
      This breaks backward compatibility, but I think it makes the argument
      more user-friendly.  If you try and set an invalid level, there's a
      helpful error message to guide you in the right direction.
      
      I also use format_exc() in Connection.dequeue (following the existing
      example deeper in the Connection.dequeue nest).  The log level should
      decide whether the traceback is printed or not, not whether the
      exception should be raised or ignored.
      0a23831b
    • W. Trevor King's avatar
      irkerd: Split imported modules onto their own lines · 14c51234
      W. Trevor King authored
      Following PEP 8 [1]:
      
        Imports should usually be on separate lines, e.g.:
      
          Yes: import os
               import sys
      
          No:  import sys, os
      
      This also makes it easier to read diffs that add and remove imports,
      since you won't need a word-diff to see exactly what changed.
      
      [1]: http://legacy.python.org/dev/peps/pep-0008/#imports
      
      Conflicts:
      	irkerd
      14c51234
    • W. Trevor King's avatar
      irkerd: Pull request-parsing out into Irker._parse_request · 8468af97
      W. Trevor King authored
      There is a lot of error checking here, which is good, but it distracts
      from the core logic of Irker.handle.  By pulling the parsing out into
      a private helper function, we isolate the code focused on parsing and
      error checking from the code focused on dispatching and connection
      management, making both easier to read.
      
      I've also changed the Target-validation logic.  The old Target.valid
      returned True if the Target URL was valid, and False otherwise.  The
      new Target.validate returns None, and raises an InvalidRequest
      exception with an error message describing exactly why the URL is
      invalid.  We print these messages when dropping server URLs in
      Irker._parse_request, while the old Irker.handle code silently dropped
      invalid targets.  We also continue processing other server URLs after
      an invalid Target, while the old Irker.handle code bailed out after
      the first invalid Target.  Besides making the invalid URLs more
      obvious in the logs and increasing resiliency to invalid URLs, these
      changes allow us to pull the URL-to-Target conversion out of
      Irker.handle entirely, so it can focus more strongly on dispatch and
      connection management.
      8468af97
    • W. Trevor King's avatar
      irkerd: Add InvalidRequest and use it to flatten Irker.handle() · aae700b1
      W. Trevor King authored
      The old implementation had several instances of logic like this:
      
        if exception_condition:
            self.logerr("invalid request")
        else:
            # continue_processing
      
      This increases nesting after each round of exception checking, and
      makes the logic of the whole function harder to follow.  This commit
      replaces that logic with:
      
        try:
            if exception_condition:
                raise InvalidRequest("invalid request")
            # continue peocessing
        except InvalidRequest, e:
            self.logerr(str(e))
      
      Because the guts of the handle() function are already inside a
      try/except block, we can add our except clause to the existing block,
      and now exception checks don't increase nesting at all.
      
      The exception to this global try/except block is the 'URL has
      unexpected type' error, where we do want a local try/except block
      inside the channel loop.  That way we get both errors about invalid
      URLs and continue to attempt valid URLs.  This matches the existing
      logic for this check, but conflicts with the current target.valid
      check (which doesn't log an error and does stop processing of further
      channels).
      aae700b1
    • W. Trevor King's avatar
      irkerd: Store less state in IRCServerConnection.connect() · 9a53ff42
      W. Trevor King authored
      We will never need the connection-time port, server_address, username,
      ircname, or password again, so don't store them.  We *do* need server
      and real_server_name for Event handling, so keep them around.
      9a53ff42
  2. Feb 04, 2014
  3. Dec 25, 2013
  4. Dec 22, 2013
  5. Dec 04, 2013
  6. Dec 03, 2013
  7. Dec 02, 2013
  8. Dec 01, 2013
    • Antoine Beaupré's avatar
      fix crash after introduction of immediate mode · fc36200e
      Antoine Beaupré authored
      this fixes the following backtrace:
      
      Exception happened during processing of request from ('127.0.0.1', 41192)
      Traceback (most recent call last):
        File /usr/lib/python2.7/SocketServer.py, line 295, in _handle_request_noblock
          self.process_request(request, client_address)
        File /usr/lib/python2.7/SocketServer.py, line 321, in process_request
          self.finish_request(request, client_address)
        File /usr/lib/python2.7/SocketServer.py, line 334, in finish_request
          self.RequestHandlerClass(request, client_address, self)
        File /usr/lib/python2.7/SocketServer.py, line 649, in __init__
          self.handle()
        File ./irkerd, line 820, in handle
          irker.handle(line.strip())
        File ./irkerd, line 786, in handle
          self.servers[target.server()].dispatch(target.channel, message, target.key, quit_after=quit_after)
        File ./irkerd, line 641, in dispatch
          eligibles[0].enqueue(channel, message, key)
      TypeError: enqueue() takes exactly 5 arguments (4 given)
      
      when running: ./irk irker-test test
      fc36200e
    • Antoine Beaupré's avatar
      add a more helpful hook example: in post-receive · 4d730bc5
      Antoine Beaupré authored
      the previous suggestion seemed to be about the update hook, but it's
      usually bad practice to setup notification hooks there, because if
      they fail, the push fails.
      
      parsing the git documentation to find exactly the incantation is not
      exactly trivial either...
      4d730bc5
    • Eric S. Raymond's avatar
      Another shipper metadata change. · f3d87f4e
      Eric S. Raymond authored
      f3d87f4e
Loading