Commits

Gregory Petukhov committed 4bcf69b

Bugfixes. README. Correct settings template

  • Participants
  • Parent commits 771f44b

Comments (0)

Files changed (15)

 syntax:glob
-*.py[co]
-logs
+*.pyc
+*.pyo
 .ropeproject
 bot.cfg
+.env
+local_settings.py
 
 syntax:regexp
 ^dist
 ^.*\.egg-info
-^local_settings.py$
 ^media/admin
+^logs$
+^var$
+Installation
+============
+
+    $ virtualenv .env
+    $ .env/bin/pip install -r requirements.txt
+    $ cp settings_local.py.template settings_local.py
+    $ vim settings_local.py
+    $ ./main.py
+#!.env/bin/python
+from time import sleep
+
+from xapy.bot import Bot
+from grab.tools.lock import assert_lock
+
+def main():
+    assert_lock('var/bot.lock')
+
+    bot = Bot()
+    bot.start()
+    try:
+        while bot.is_alive():
+            sleep(0.5)
+    except BaseException, e:
+        print "Stopping bot"
+        bot.stop()
+
+
+if __name__ == '__main__':
+    main()

File requirements.txt

+xmpppy==0.5.0rc1
+simplejson
+grab
+# -*- coding: utf-8 -*- 
+from settings_local import *

File settings_local.py

+# -*- coding: utf-8 -*- 
+PROCESSORS_POOL = 3
+GOOGLE_KEY = ''
+KEEPALIVE_TIMEOUT = 300
+PROTOCOL_CLASSES = ['xapy.protocols.jabber.JabberProtocol']
+PROCESSORS = []
+
+CONNECTIONS = [{
+    'name': 'py_logger',
+    'enabled': True,
+    'protocol': 'jabber',
+    'jid': 'grablab@jabber.ru',
+    'name': 'py_logger',
+    'password': 'TaNpfu9TAF',
+    'confs':  [{
+        'jid': 'grablab@conference.jabber.ru',
+        'password': 'asdf',
+        'name': u'ivanbot',
+    }],
+}]
+
+PROCESSORS = [
+    'xapy.processors.chat_log',
+]

File settings_local.py.template

+# -*- coding: utf-8 -*- 
+PROCESSORS_POOL = 3
+GOOGLE_KEY = ''
+KEEPALIVE_TIMEOUT = 300
+PROTOCOL_CLASSES = ['xapy.protocols.jabber.JabberProtocol']
+PROCESSORS = []
+
+CONNECTIONS = [{
+    'name': 'py_logger',
+    'enabled': True,
+    'protocol': 'jabber',
+    'jid': '...',
+    'name': 'py_logger',
+    'password': '...',
+    'confs':  [{
+        'jid': 'grablab@conference.jabber.ru',
+        'password': 'asdf',
+        'name': u'...',
+    }],
+}]
+
+PROCESSORS = [
+    'xapy.processors.chat_log',
+]
 # -*- coding: utf-8 -*-
 import logging
 
-from xapy import settings
 from xapy.cpu import Cpu
 from xapy.common import import_attr
 from xapy.protocol import Protocol
 from xapy.exceptions import UnknownProtocol
 from xapy.processors import *
 
+import settings
+
 
 logging.basicConfig(level=logging.DEBUG,
                     format='%(asctime)s %(levelname)s %(name)s: %(message)s')

File xapy/connection.py

 import logging
 import thread, threading
 
-from xapy import settings
 from xapy.message import Message
 from xapy.exceptions import *
 
+import settings
+
 class Connection(threading.Thread):
     """threaded connection"""
 
 import threading
 from Queue import Empty
 
-from xapy import settings
+import settings
 
 class Worker(threading.Thread):
     """worker, who applies processors to messages"""

File xapy/exceptions.py

 class UnknownProtocol(Exception): 
     pass  
 
-class ProtocolErrot(Exception):
+class ProtocolError(Exception):
     pass
-class FinishProcessing(ProtocolErrot):
+
+class FinishProcessing(ProtocolError):
     pass
 
 class ProcessorError(Exception): 
     pass
+
 class LastProcessor(ProcessorError): 
     pass
 

File xapy/processors/chat_log.py

 class Processor(ProcessorBase):
     protocol = 'all'  #protocol name
     low_level = 0 # 1 if lowlevel for protocol
-    logs_dir = op.join(op.dirname(__file__), '..', 'logs')
+    logs_dir = op.join(op.dirname(__file__), '../..', 'logs')
     log_chatrooms = ''
     last_dates = {}
 

File xapy/protocols/jabber.py

 
 import xmpp
 
-from xapy.exceptions import StringNotReadyError, ProtocolErrot
+from xapy.exceptions import StringNotReadyError, ProtocolError
 from xapy.protocol import Protocol
 from xapy.message import Message
 from xapy.user import User

File xapy/requirements.pip

-BeautifulSoup==3.2.0
-distribute==0.6.10
-simplejson==2.1.3
-xmpppy==0.5.0rc1

File xapy/settings.py.template

-# -*- coding: utf-8 -*- 
-
-PROCESSORS_POOL = 3
-GOOGLE_KEY = ''
-KEEPALIVE_TIMEOUT = 300
-
-
-CONNECTIONS = [
-        {
-            'name': 'py_logger',
-            'enabled': True,
-            'protocol': 'jabber',
-            'jid': 'py_logger@jabber.ru',
-            'name': 'py_logger',
-            'password': 'password',
-            'confs':  [
-                {'jid': 'testcon@conference.jabber.ru',
-                 'password': 'password',
-                 'name': u'optional name'},
-                {'jid': 'conference2@conference.jabber.ru',
-                 'password':'',
-                 },
-                        ],
-            },
-        ]