Merge lp://staging/~ricardokirkner/lalita/trunk-easy_install into lp://staging/lalita

Proposed by Ricardo Kirkner
Status: Merged
Merged at revision: not available
Proposed branch: lp://staging/~ricardokirkner/lalita/trunk-easy_install
Merge into: lp://staging/lalita
Diff against target: 664 lines (+180/-76)
18 files modified
INSTALL (+52/-1)
LICENSE (+1/-0)
README (+4/-1)
lalita.cfg.sample (+24/-23)
setup.py (+43/-0)
src/lalita/__init__.py (+1/-0)
src/lalita/core/dispatcher.py (+1/-1)
src/lalita/core/tests/plugins/testbot.py (+1/-1)
src/lalita/core/tests/test_dispatcher.py (+1/-4)
src/lalita/core/tests/test_events.py (+1/-2)
src/lalita/core/tests/test_flowcontrol.py (+1/-1)
src/lalita/core/tests/test_metacommands.py (+1/-3)
src/lalita/ircbot.py (+23/-16)
src/lalita/plugins/randomer_utils/randomer.py (+10/-6)
src/lalita/plugins/tests/helper.py (+1/-1)
src/lalita/plugins/tests/test_example.py (+3/-3)
src/lalita/plugins/tests/test_misc.py (+3/-3)
src/lalita/plugins/tests/test_seen.py (+9/-10)
To merge this branch: bzr merge lp://staging/~ricardokirkner/lalita/trunk-easy_install
Reviewer Review Type Date Requested Status
Ricardo Kirkner Needs Resubmitting
Facundo Batista Needs Fixing
Review via email: mp+16215@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Ricardo Kirkner (ricardokirkner) wrote :

Adapt the code so that it is easily "easy_install"-able. Just moved some stuff around, added the necessary packaging stuff and slightly changed the ircbot.py file to use a configuration file passed by parameter.

From the code on this branch I already added lalita to the PyPI, and it worked alright (I could 'easy_install lalita').

129. By Ricardo Kirkner

extra packaging enhancements

. use package resources instead of paths
. include all versioned content in package data for source and binary distributions

130. By Ricardo Kirkner

small fix in pkg_resource handling

Revision history for this message
Facundo Batista (facundo) wrote :

Hi!

This looks very nice! One issue, though (see question #3).

A couple of questions....

1) It's ok that the config file is not "hardcoded", but given as an argument. But, if it is mandatory, why pass it like a parameter? I mean, why have a "-c" for it, instead of giving it as a first arg?

Instead of what this patch says as mandatory...

    ircbot.py [bunch of optional args] -c config_file server1 [server2 [...]]

... I propose ...

    ircbot.py [bunch of optional args] config_file server1 [server2 [...]]

(so, no "-c" for the config file).

What do you think?

2) I did "python setup.py build", and "sudo python setup.py install"... it downloaded the Twisted library again in this process... is it always needed or it should identify that I have that library already installed?

3) Finally, the setup process failed with (full log attached):

    error: Setup script exited with error: command 'gcc' failed with exit status 1

Did I do something wrong? Are the steps somewhat different?

(btw, this is why the "need fixing" in the review)

4) If I want to generate just the .egg, not install the program, what should I do?

Thanks for everything, this is good work! Hope that small issue is easily fixed, so we can have this in trunk!

review: Needs Fixing
Revision history for this message
Facundo Batista (facundo) wrote :
Download full text (25.6 KiB)

facundo@phenomenux:~/devel/reps/lalita/review_trunk-easy_install$ ll
total 80
drwxr-xr-x 2 facundo facundo 4096 2010-01-17 09:25 db
drwxr-xr-x 2 facundo facundo 4096 2010-01-17 09:25 docs
-rw-r--r-- 1 facundo facundo 35147 2010-01-17 09:25 gpl-3.0.txt
-rw-r--r-- 1 facundo facundo 666 2010-01-17 09:53 INSTALL
-rw-r--r-- 1 facundo facundo 5860 2010-01-17 09:25 lalita.cfg.sample
-rw-r--r-- 1 facundo facundo 1008 2010-01-17 09:25 LICENSE
-rwxr-xr-x 1 facundo facundo 1014 2010-01-17 09:25 notes.txt
-rw-r--r-- 1 facundo facundo 1602 2010-01-17 09:25 README
drwxr-xr-x 2 facundo facundo 4096 2010-01-17 09:25 scripts
-rwxr-xr-x 1 facundo facundo 1243 2010-01-17 09:25 setup.py
drwxr-xr-x 3 facundo facundo 4096 2010-01-17 09:25 src
facundo@phenomenux:~/devel/reps/lalita/review_trunk-easy_install$ python setup.py build
running build
running build_py
creating build
creating build/lib.linux-i686-2.6
creating build/lib.linux-i686-2.6/lalita
copying src/lalita/__init__.py -> build/lib.linux-i686-2.6/lalita
copying src/lalita/ircbot.py -> build/lib.linux-i686-2.6/lalita
creating build/lib.linux-i686-2.6/lalita/plugins
copying src/lalita/plugins/seen.py -> build/lib.linux-i686-2.6/lalita/plugins
copying src/lalita/plugins/freenode.py -> build/lib.linux-i686-2.6/lalita/plugins
copying src/lalita/plugins/__init__.py -> build/lib.linux-i686-2.6/lalita/plugins
copying src/lalita/plugins/example.py -> build/lib.linux-i686-2.6/lalita/plugins
copying src/lalita/plugins/url.py -> build/lib.linux-i686-2.6/lalita/plugins
copying src/lalita/plugins/randomer.py -> build/lib.linux-i686-2.6/lalita/plugins
copying src/lalita/plugins/moin_search.py -> build/lib.linux-i686-2.6/lalita/plugins
copying src/lalita/plugins/archives_search.py -> build/lib.linux-i686-2.6/lalita/plugins
copying src/lalita/plugins/plugin.py -> build/lib.linux-i686-2.6/lalita/plugins
copying src/lalita/plugins/misc.py -> build/lib.linux-i686-2.6/lalita/plugins
creating build/lib.linux-i686-2.6/lalita/core
copying src/lalita/core/dispatcher.py -> build/lib.linux-i686-2.6/lalita/core
copying src/lalita/core/__init__.py -> build/lib.linux-i686-2.6/lalita/core
copying src/lalita/core/events.py -> build/lib.linux-i686-2.6/lalita/core
copying src/lalita/core/flowcontrol.py -> build/lib.linux-i686-2.6/lalita/core
creating build/lib.linux-i686-2.6/lalita/plugins/randomer_utils
copying src/lalita/plugins/randomer_utils/__init__.py -> build/lib.linux-i686-2.6/lalita/plugins/randomer_utils
copying src/lalita/plugins/randomer_utils/randomer.py -> build/lib.linux-i686-2.6/lalita/plugins/randomer_utils
running egg_info
creating src/lalita.egg-info
writing requirements to src/lalita.egg-info/requires.txt
writing src/lalita.egg-info/PKG-INFO
writing top-level names to src/lalita.egg-info/top_level.txt
writing dependency_links to src/lalita.egg-info/dependency_links.txt
writing manifest file 'src/lalita.egg-info/SOURCES.txt'
writing manifest file 'src/lalita.egg-info/SOURCES.txt'
creating build/lib.linux-i686-2.6/lalita/plugins/tests
copying src/lalita/plugins/tests/__init__.py -> build/lib.linux-i686-2.6/lalita/plugins/tests
copying src/lalita/plugins/tests/helper.py -> build/lib.linux-i686-2.6/lalita/plugin...

Revision history for this message
Ricardo Kirkner (ricardokirkner) wrote :

> Hi!
>
> This looks very nice! One issue, though (see question #3).
>
>
> A couple of questions....
>
> 1) It's ok that the config file is not "hardcoded", but given as an argument.
> But, if it is mandatory, why pass it like a parameter? I mean, why have a "-c"
> for it, instead of giving it as a first arg?
>
> Instead of what this patch says as mandatory...
>
> ircbot.py [bunch of optional args] -c config_file server1 [server2 [...]]
>
> ... I propose ...
>
> ircbot.py [bunch of optional args] config_file server1 [server2 [...]]
>
> (so, no "-c" for the config file).
>
> What do you think?
>

FIXED in rev. 134

>
> 2) I did "python setup.py build", and "sudo python setup.py install"... it
> downloaded the Twisted library again in this process... is it always needed or
> it should identify that I have that library already installed?
>

This was due a bug in setuptools.

FIXED in rev. 134 by requiring a newer setuptools that fixes the issue.

>
> 3) Finally, the setup process failed with (full log attached):
>
> error: Setup script exited with error: command 'gcc' failed with exit
> status 1
>
> Did I do something wrong? Are the steps somewhat different?
>
> (btw, this is why the "need fixing" in the review)
>

Sqlite3 development headers were required to build pysqlite. Added the requirement to the INSTALL file.

>
> 4) If I want to generate just the .egg, not install the program, what should I
> do?
>

Added the steps to the INSTALL file.

review: Needs Resubmitting
131. By Ricardo Kirkner

fixes setuptools issues with finding installed packages

132. By Ricardo Kirkner

configuration filename is required

133. By Ricardo Kirkner

updated INSTALL doc

134. By Ricardo Kirkner

merged in latest trunk (rev. 126)

Revision history for this message
Facundo Batista (facundo) wrote :

I'm working on this.

I already fixed some small issues, but I'd want to discuss a little about setuptools version, how to get Twisted dependency working, and maybe use distutils for better compatibility.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'INSTALL'
2--- INSTALL 2009-05-20 17:05:41 +0000
3+++ INSTALL 2010-01-17 19:06:14 +0000
4@@ -1,8 +1,59 @@
5-There's no install. You just run the bot from the directory where you get it.
6+QUICK HOWTO
7+-----------
8+
9+This package has a setuptools compatible setup.py file.
10+If all requirements are met, just follow the usual steps, e.g.
11+
12+python setup.py install -- to install it into the site-packages folder
13+
14+Alternatively, you can run the bot directly from the directory where you get it.
15+
16 Just a couple of things:
17
18 * Depends on twisted (more specificaly, twisted words) and python-pysqlite2.
19
20+ * Sqlite3 has to be installed (specifically its headers).
21+
22 * url.Url plugin depends on Beautiful Soup v3.1.0.1 or similar (just check that
23 XHTML_ENTITIES exist), python-magic and python-chardet (and twisted web, just
24 in case you installed a partial twisted).
25+
26+ * All dependencies but python-magic are automatically installed by the setup
27+ script upon installation.
28+
29+
30+BUILD STEPS
31+-----------
32+
33+For building the package without installing, choose any of the following:
34+
35+a. Build the package
36+
37+ python setup.py build
38+
39+b. Build a binary distribution
40+
41+ python setup.py bdist
42+
43+c. Build a source distribution
44+
45+ python setup.py sdist
46+
47+d. Build an .egg file
48+
49+ python setup.py bdist_egg
50+
51+
52+INSTALL STEPS
53+-------------
54+
55+For installing on a completely clean system, follow the steps (as root):
56+
57+1. Install sqlite3 headers
58+
59+ apt-get install libsqlite3-dev
60+
61+2. Build and install the package
62+
63+ python setup.py install
64+
65
66=== modified file 'LICENSE'
67--- LICENSE 2009-10-20 03:35:45 +0000
68+++ LICENSE 2010-01-17 19:06:14 +0000
69@@ -24,6 +24,7 @@
70 javimansilla
71 matiasb
72 perrito666
73+ Ricardo Kirkner
74
75 ... but you can get the info updated in:
76
77
78=== modified file 'README'
79--- README 2010-01-05 23:59:51 +0000
80+++ README 2010-01-17 19:06:14 +0000
81@@ -18,7 +18,10 @@
82
83 https://edge.launchpad.net/lalita
84
85-To run the bot, rename config.py.examples to config.py and run ircbot.py
86+To run the bot, create a config file (you can use the sample lalita.cfg.sample)
87+as a guideline, and run
88+
89+ircbot.py -c <configfile> <server>
90
91 There're a lot of test cases! You can try them running "nosetests" (you
92 need to have Nose installed).
93
94=== renamed file 'config.py.example' => 'lalita.cfg.sample'
95--- config.py.example 2009-11-15 01:02:37 +0000
96+++ lalita.cfg.sample 2010-01-17 19:06:14 +0000
97@@ -17,13 +17,14 @@
98 '#perrites': dict (
99 lang='en',
100 plugins={
101- 'seen.Seen': {'base_dir':'<path/to/shelves_dir>'}, # two shelf's are going to be created (iolog and saylog)
102+ # two shelves are going to be created (iolog and saylog)
103+ 'lalita.plugins.seen.Seen': {'base_dir':'<path/to/shelves_dir>'},
104 }),
105 },
106 plugins= {
107 # 'url.Url': { },
108 # 'seen.Seen': { },
109- 'misc.Ping': { },
110+ 'lalita.plugins.misc.Ping': { },
111 },
112 ),
113 'example': dict (
114@@ -34,7 +35,7 @@
115 '#humites': dict(plugins={}),
116 },
117 plugins= {
118- 'example.Example': { },
119+ 'lalita.plugins.example.Example': { },
120 },
121 ),
122 'private-server': dict (
123@@ -47,7 +48,7 @@
124 '#humites': dict(plugins={}),
125 },
126 plugins= {
127- 'example.Example': { },
128+ 'lalita.plugins.example.Example': { },
129 },
130 ),
131 'freenode': dict (
132@@ -65,10 +66,10 @@
133 }),
134 },
135 plugins= {
136- 'freenode.Register': { 'password': 'zaraza' },
137- 'url.Url': { },
138- 'seen.Seen': { },
139- 'misc.Ping': { },
140+ 'lalita.plugins.freenode.Register': { 'password': 'zaraza' },
141+ 'lalita.plugins.url.Url': { },
142+ 'lalita.plugins.seen.Seen': { },
143+ 'lalita.plugins.misc.Ping': { },
144 },
145 ),
146 'perrito':{
147@@ -79,27 +80,27 @@
148 'channels':{
149 '#humites':{
150 'plugins':{
151- 'url.Url': dict (
152+ 'lalita.plugins.url.Url': dict (
153 database= 'url_public',
154 ),
155- 'seen.Seen': {},
156+ 'lalita.plugins.seen.Seen': {},
157 },
158 'encoding': 'utf8',
159 },
160 '#perrites':{
161 'encoding': 'utf8',
162 'plugins':{
163- 'url.Url': dict (
164+ 'lalita.plugins.url.Url': dict (
165 database= 'url_perrites_private',
166 ),
167 },
168 },
169 },
170 'plugins':{
171- 'url.Url': dict (
172+ 'lalita.plugins.url.Url': dict (
173 database= 'url_public',
174 ),
175- 'seen.Seen': {},
176+ 'lalita.plugins.seen.Seen': {},
177 }
178 },
179 'testbot-a':{
180@@ -113,9 +114,9 @@
181 },
182 },
183 'plugins':{
184- 'testbot.TestPlugin': {'other': 'scratchy'}
185+ 'lalita.plugins.testbot.TestPlugin': {'other': 'scratchy'}
186 },
187- 'plugins_dir': "./core/tests/plugins",
188+ 'plugins_dir': "./src/lalita/core/tests/plugins",
189 },
190 'testbot-b':{
191 'encoding': 'utf8',
192@@ -128,9 +129,9 @@
193 },
194 },
195 'plugins':{
196- 'testbot.TestPlugin': {'other':'itchy'}
197+ 'lalita.plugins.testbot.TestPlugin': {'other':'itchy'}
198 },
199- 'plugins_dir': "./core/tests/plugins",
200+ 'plugins_dir': "./src/lalita/core/tests/plugins",
201 },
202 'perrito1':{
203 'encoding': 'utf8',
204@@ -139,15 +140,15 @@
205 'nickname' : "lolita",
206 'channels':{
207 '#humites':{
208- 'plugins':{ 'Log':{} },
209+ 'plugins':{ 'lalita.plugins.Log':{} },
210 'encoding': 'utf8',
211 },
212 '#perrites':{
213- 'plugins':{ 'Log':{} }
214+ 'plugins':{ 'lalita.plugins.Log':{} }
215 }
216 },
217 'plugins':{
218- 'Log': {}
219+ 'lalita.plugins.Log': {}
220 }
221 },
222 'pyar2':{
223@@ -157,12 +158,12 @@
224 'nickname' : "apu",
225 'channels':{
226 'pyar':{
227- 'plugins':{ 'Log':{} },
228+ 'plugins':{ 'lalita.plugins.Log':{} },
229 'encoding': 'utf8',
230 },
231 },
232 'plugins':{
233- 'Log': {}
234+ 'lalita.plugins.Log': {}
235 }
236 },
237 'javito':{
238@@ -173,7 +174,7 @@
239 'channels':{
240 '#humites':{
241 'plugins':{
242- 'randomer.Randomer': dict (
243+ 'lalita.plugins.randomer.Randomer': dict (
244 database= 'url_public',
245 )
246 },
247
248=== added file 'setup.py'
249--- setup.py 1970-01-01 00:00:00 +0000
250+++ setup.py 2010-01-17 19:06:14 +0000
251@@ -0,0 +1,43 @@
252+#!/usr/bin/env python
253+from setuptools import setup, find_packages
254+
255+setup(
256+ # metadata
257+ name='lalita',
258+ version='0.1',
259+ maintainer='laliputienses',
260+ maintainer_email='',
261+ description='Yet another IRC bot, one where new functionality is simple ' \
262+ 'to create just adding easy-to-write plugins.',
263+ license='GNU GPL v3 ',
264+ keywords=['irc', 'bot', 'twisted', 'plugin'],
265+ url='https://launchpad.net/lalita/',
266+ classifiers=[
267+ 'Development Status :: 5 - Production/Stable',
268+ 'Environment :: Console',
269+ 'Framework :: Twisted',
270+ 'Intended Audience :: Developers',
271+ 'License :: OSI Approved :: GNU General Public License (GPL)',
272+ 'Programming Language :: Python',
273+ 'Topic :: Communications :: Chat :: Internet Relay Chat',
274+ ],
275+
276+ # content
277+ package_dir={'': 'src'},
278+ packages=find_packages('src',
279+ exclude=['*.tests', '*.tests.*', 'tests.*', 'tests']),
280+ include_package_data=True,
281+
282+ # scripts
283+ scripts=['src/lalita/ircbot.py'],
284+
285+ # dependencies
286+ setup_requires=['setuptools>=0.6c10', 'setuptools-bzr'],
287+ install_requires=[
288+ 'beautifulsoup',
289+ 'chardet',
290+ 'pyopenssl',
291+ 'pysqlite',
292+ 'twisted',
293+ ],
294+)
295
296=== added directory 'src'
297=== added directory 'src/lalita'
298=== added file 'src/lalita/__init__.py'
299--- src/lalita/__init__.py 1970-01-01 00:00:00 +0000
300+++ src/lalita/__init__.py 2010-01-17 19:06:14 +0000
301@@ -0,0 +1,1 @@
302+from core import Plugin, dispatcher, events
303
304=== renamed directory 'core' => 'src/lalita/core'
305=== modified file 'src/lalita/core/dispatcher.py'
306--- core/dispatcher.py 2009-12-22 00:37:38 +0000
307+++ src/lalita/core/dispatcher.py 2010-01-17 19:06:14 +0000
308@@ -13,7 +13,7 @@
309 import logging
310 logger = logging.getLogger ('ircbot.core.dispatcher')
311
312-from core import events, flowcontrol
313+from . import events, flowcontrol
314
315 # messages longer than this will be splitted in different server commands
316 LENGTH_MSG = 512
317
318=== modified file 'src/lalita/core/tests/plugins/testbot.py'
319--- core/tests/plugins/testbot.py 2010-01-17 16:10:08 +0000
320+++ src/lalita/core/tests/plugins/testbot.py 2010-01-17 19:06:14 +0000
321@@ -7,7 +7,7 @@
322 # This is not a standard test case, but a special plugin that expect
323 # to be instantiated twice to talk to each other
324
325-from core import events as evt
326+from lalita.core import events as evt
327
328
329 class TestPlugin(object):
330
331=== modified file 'src/lalita/core/tests/test_dispatcher.py'
332--- core/tests/test_dispatcher.py 2010-01-17 16:10:08 +0000
333+++ src/lalita/core/tests/test_dispatcher.py 2010-01-17 19:06:14 +0000
334@@ -9,10 +9,7 @@
335 from twisted.trial.unittest import TestCase as TwistedTestCase
336 from twisted.internet import defer, reactor
337
338-from core import events
339-from core import dispatcher
340-from core import Plugin
341-import ircbot
342+from lalita import Plugin, dispatcher, events, ircbot
343
344 server = dict(
345 encoding='utf8',
346
347=== modified file 'src/lalita/core/tests/test_events.py'
348--- core/tests/test_events.py 2010-01-17 16:10:08 +0000
349+++ src/lalita/core/tests/test_events.py 2010-01-17 19:06:14 +0000
350@@ -6,8 +6,7 @@
351 from twisted.trial.unittest import TestCase as TwistedTestCase
352 from twisted.internet import defer
353
354-from core import events
355-import ircbot
356+from lalita import dispatcher, events, ircbot
357
358 server = dict(
359 encoding='utf8',
360
361=== modified file 'src/lalita/core/tests/test_flowcontrol.py'
362--- core/tests/test_flowcontrol.py 2010-01-17 16:10:08 +0000
363+++ src/lalita/core/tests/test_flowcontrol.py 2010-01-17 19:06:14 +0000
364@@ -7,7 +7,7 @@
365 from twisted.trial.unittest import TestCase as TwistedTestCase
366 from twisted.internet import defer, reactor
367
368-from core import flowcontrol
369+from lalita.core import flowcontrol
370
371
372 class TestBaseFC(unittest.TestCase):
373
374=== modified file 'src/lalita/core/tests/test_metacommands.py'
375--- core/tests/test_metacommands.py 2010-01-17 16:10:08 +0000
376+++ src/lalita/core/tests/test_metacommands.py 2010-01-17 19:06:14 +0000
377@@ -8,9 +8,7 @@
378
379 from collections import defaultdict
380
381-from core import events
382-from core import dispatcher
383-import ircbot
384+from lalita import dispatcher, events, ircbot
385
386 ircbot_factory = ircbot.IRCBotFactory(dict(log_config="error", channels=defaultdict(lambda: {})))
387 ircbot.logger.setLevel("error")
388
389=== renamed file 'ircbot.py' => 'src/lalita/ircbot.py'
390--- ircbot.py 2010-01-17 16:10:08 +0000
391+++ src/lalita/ircbot.py 2010-01-17 19:06:14 +0000
392@@ -15,16 +15,13 @@
393 import optparse
394 from traceback import print_exc
395
396-# if we're in production, this should work and no magic is necessary
397-try:
398- import lalita
399-except ImportError:
400- import core
401- sys.modules["lalita"] = core
402+# twisted imports
403+from twisted.internet import reactor, protocol, ssl
404+from twisted.python import log
405+from twisted.words.protocols import irc
406
407 # local imports
408-from core import events
409-from core import dispatcher
410+from lalita import dispatcher, events
411
412 LOG_LEVELS = {
413 "debug": logging.DEBUG,
414@@ -43,6 +40,7 @@
415 logger.addHandler(log_stdout_handler)
416 logger.setLevel(logging.DEBUG)
417
418+
419 class IrcBot (irc.IRCClient):
420 """A IRC bot."""
421 def __init__ (self, *more):
422@@ -58,10 +56,10 @@
423 'plugins')
424 sys.path.append(path)
425
426- modname, klassname= plugin_name.split ('.')
427+ modname, klassname= plugin_name.rsplit ('.', 1)
428 loglvl = self.config["log_config"].get(plugin_name)
429 try:
430- module = __import__(modname)
431+ module = __import__(modname, globals(), locals(), [''])
432 klass = getattr(module, klassname)
433 instance = klass(params, loglvl)
434 self.dispatcher.new_plugin(instance, channel)
435@@ -300,9 +298,10 @@
436
437 if __name__ == '__main__':
438 msg = """
439- ircbot.py [-t][-a][-o output_loglvl][-p plugins_loglvl]
440+ ircbot.py config_filename [-t][-a][-o output_loglvl][-p plugins_loglvl]
441 [-f fileloglvl][-n logfname] [server1, [...]]
442
443+ the config_filename is required
444 the servers are optional if -a is passed
445 the output_loglevel is the log level for the standard output
446 the file_loglevel is the log level for the output that goes to file
447@@ -347,8 +346,15 @@
448 test = bool(options.test)
449 all_servers = bool(options.all_servers)
450
451+ # control the configuration file
452+ if len(args) < 1:
453+ parser.print_help()
454+ exit()
455+ else:
456+ config_filename = args[0]
457+
458 # control the servers
459- if not args and not all_servers and not test:
460+ if len(args) < 2 and not all_servers and not test:
461 parser.print_help()
462 exit()
463
464@@ -382,10 +388,11 @@
465 raise
466
467 try:
468- import config
469+ config = {}
470+ execfile(config_filename, config)
471 except ImportError:
472 print "A config file is needed to run this program."
473- print "See as an example the included here config.py.example"
474+ print "See as an example the included here lalita.cfg.sample"
475 sys.exit()
476
477 # handles the log file and its level
478@@ -409,13 +416,13 @@
479 logger.addHandler(fh)
480
481 # get all servers or the indicated ones
482- servers = config.servers
483+ servers = config.get('servers', {})
484 if all_servers:
485 to_use = [v for k,v in servers.items() if not k.startswith("testbot")]
486 elif test:
487 to_use = [servers[x] for x in ("testbot-a", "testbot-b")]
488 else:
489- to_use = [servers[x] for x in args]
490+ to_use = [servers[x] for x in args[1:]]
491
492 if options.manhole:
493 manhole_opts = dict(user=options.manhole_user,
494
495=== renamed directory 'plugins' => 'src/lalita/plugins'
496=== modified file 'src/lalita/plugins/randomer_utils/randomer.py'
497--- plugins/randomer_utils/randomer.py 2009-10-20 03:35:45 +0000
498+++ src/lalita/plugins/randomer_utils/randomer.py 2010-01-17 19:06:14 +0000
499@@ -4,14 +4,18 @@
500 # License: GPL v3
501 # For further info, see LICENSE file
502
503+import os
504+import pkg_resources
505 import re
506 import sqlite3
507 from random import random, randrange
508-import os
509-
510-puaj_path = os.path.dirname(__file__)
511-
512-conn = sqlite3.connect(os.path.join(puaj_path,'logs.sqlite'))
513+
514+if pkg_resources.resource_exists(__name__, 'logs.sqlite'):
515+ db_filename = pkg_resources.resource_filename(__name__, 'logs.sqlite')
516+else:
517+ db_filename = 'logs.sqlite'
518+
519+conn = sqlite3.connect(db_filename)
520 cursor = conn.cursor()
521
522 def magic(line):
523@@ -25,7 +29,7 @@
524 cursor.execute("""create table logs (id integer primary key, next integer, whom text, txt text, magic real)""")
525 pattern = re.compile('\d\d:\d\d <.([^>]*)> (.*)')
526 personal_pattern = re.compile('[^:]*:(.*)')
527- logs = file(os.path.join(puaj_path,'#pyar.log')).read()
528+ logs = pkg_resources.resource_string(__name__, '#pyar.log')
529 matchs = re.findall(pattern,logs)
530 matchs.reverse()
531 for name,match in matchs:
532
533=== modified file 'src/lalita/plugins/tests/helper.py'
534--- plugins/tests/helper.py 2009-11-15 01:02:37 +0000
535+++ src/lalita/plugins/tests/helper.py 2010-01-17 19:06:14 +0000
536@@ -4,7 +4,7 @@
537
538 import unittest
539
540-import ircbot
541+from lalita import ircbot
542
543
544 class PluginTest(unittest.TestCase):
545
546=== modified file 'src/lalita/plugins/tests/test_example.py'
547--- plugins/tests/test_example.py 2009-11-15 01:02:37 +0000
548+++ src/lalita/plugins/tests/test_example.py 2010-01-17 19:06:14 +0000
549@@ -4,10 +4,10 @@
550 # License: GPL v3
551 # For further info, see LICENSE file
552
553-from core import events
554-
555+from lalita import events
556 from .helper import PluginTest
557
558+
559 class TestMethods(PluginTest):
560 '''Example of unit test for plugins.
561
562@@ -19,7 +19,7 @@
563
564 def setUp(self):
565 '''Just init your module.Class.'''
566- self.init("example.Example")
567+ self.init("lalita.plugins.example.Example")
568
569 def test_private(self):
570 '''Check 'private' functionality.'''
571
572=== modified file 'src/lalita/plugins/tests/test_misc.py'
573--- plugins/tests/test_misc.py 2009-10-20 03:35:45 +0000
574+++ src/lalita/plugins/tests/test_misc.py 2010-01-17 19:06:14 +0000
575@@ -4,13 +4,13 @@
576 # License: GPL v3
577 # For further info, see LICENSE file
578
579-from core import events
580-
581+from lalita import events
582 from .helper import PluginTest
583
584+
585 class TestPing(PluginTest):
586 def setUp(self):
587- self.init("misc.Ping")
588+ self.init("lalita.plugins.misc.Ping")
589
590 def test_ping(self):
591 '''Test ping.'''
592
593=== modified file 'src/lalita/plugins/tests/test_seen.py'
594--- plugins/tests/test_seen.py 2009-10-20 03:35:45 +0000
595+++ src/lalita/plugins/tests/test_seen.py 2010-01-17 19:06:14 +0000
596@@ -4,19 +4,18 @@
597 # License: GPL v3
598 # For further info, see LICENSE file
599
600-from core import events
601-
602-from .helper import PluginTest
603-
604 import os
605 import re
606 import shutil
607 import tempfile
608
609+from lalita import events
610+from .helper import PluginTest
611+
612
613 class TestLog(PluginTest):
614 def setUp(self):
615- self.init("seen.Seen")
616+ self.init("lalita.plugins.seen.Seen")
617
618 def test_joined(self):
619 '''Logs joined.'''
620@@ -51,7 +50,7 @@
621
622 class TestSeen(PluginTest):
623 def setUp(self):
624- self.init("seen.Seen")
625+ self.init("lalita.plugins.seen.Seen")
626
627 def test_plugin(self):
628 '''User asks about the bot.'''
629@@ -171,7 +170,7 @@
630
631 class TestLast(PluginTest):
632 def setUp(self):
633- self.init("seen.Seen")
634+ self.init("lalita.plugins.seen.Seen")
635
636 def test_plugin(self):
637 '''User asks about the bot.'''
638@@ -282,7 +281,7 @@
639 def setUp(self):
640 self.base_dir = tempfile.mktemp()
641 os.makedirs(self.base_dir)
642- self.init("seen.Seen", {'base_dir':self.base_dir})
643+ self.init("lalita.plugins.seen.Seen", {'base_dir':self.base_dir})
644
645 def tearDown(self):
646 shutil.rmtree(self.base_dir)
647@@ -293,7 +292,7 @@
648 def setUp(self):
649 self.base_dir = tempfile.mktemp()
650 os.makedirs(self.base_dir)
651- self.init("seen.Seen", {'base_dir':self.base_dir})
652+ self.init("lalita.plugins.seen.Seen", {'base_dir':self.base_dir})
653
654 def tearDown(self):
655 shutil.rmtree(self.base_dir)
656@@ -304,7 +303,7 @@
657 def setUp(self):
658 self.base_dir = tempfile.mktemp()
659 os.makedirs(self.base_dir)
660- self.init("seen.Seen", {'base_dir':self.base_dir})
661+ self.init("lalita.plugins.seen.Seen", {'base_dir':self.base_dir})
662
663 def tearDown(self):
664 shutil.rmtree(self.base_dir)

Subscribers

People subscribed via source and target branches