~ubuntu-branches/ubuntu/utopic/gozerbot/utopic

« back to all changes in this revision

Viewing changes to debian/gozerbot/usr/share/gozerbot/pickletodb.py

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Malcolm
  • Date: 2009-09-14 09:00:29 UTC
  • mfrom: (1.1.4 upstream) (3.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20090914090029-uval0ekt72kmklxw
Tags: 0.9.1.3-3
Changed dependency on python-setuptools to python-pkg-resources
(Closes: #546435) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
#
3
 
#
4
 
 
5
 
from gozerbot.datadir import datadir
6
 
from gozerbot.db import db
7
 
import os
8
 
 
9
 
print "ADDING USERS"
10
 
 
11
 
from gozerbot.users import Users
12
 
u = Users(datadir + os.sep + 'users')
13
 
for i in u.data:
14
 
    for j in i.userhosts:
15
 
        print i.name, j
16
 
        try:
17
 
            db.execute(""" INSERT INTO userhosts(userhost, name) \
18
 
VALUES(%s, %s)  """, (j, i.name))
19
 
        except Exception, ex:
20
 
            print ex            
21
 
    for j in i.perms:
22
 
        print i.name, j
23
 
        try:
24
 
            db.execute(""" INSERT INTO perms(name, perm) \
25
 
VALUES(%s, %s)  """, (i.name, j))
26
 
        except Exception, ex:
27
 
            print ex            
28
 
    if i.email:
29
 
        print i.name, i.email
30
 
        try:
31
 
            db.execute(""" INSERT INTO email(name, email) \
32
 
VALUES(%s, %s)  """, (i.name, i.email))
33
 
        except Exception, ex:
34
 
            print ex            
35
 
    for j in i.permit:
36
 
        print i.name, j
37
 
        try:
38
 
            db.execute(""" INSERT INTO permits(name, permit) \
39
 
VALUES(%s, %s)  """, (i.name, j))
40
 
        except Exception, ex:
41
 
            print ex            
42
 
    for j in i.status:
43
 
        print i.name, j
44
 
        try:
45
 
            db.execute(""" INSERT INTO statuses(name, status) \
46
 
VALUES(%s, %s)  """, (i.name, j))
47
 
        except Exception, ex:
48
 
            print ex            
49
 
    if i.passwd:
50
 
        print i.name, i.passwd
51
 
        try:
52
 
            db.execute(""" INSERT INTO passwords(name, passwd) \
53
 
VALUES(%s, %s)  """, (i.name, i.passwd))
54
 
        except Exception, ex:
55
 
            print ex            
56
 
 
57
 
from gozerplugs.plugs.infoitem import Infoitems
58
 
info = Infoitems(datadir + os.sep + 'infoitems')
59
 
 
60
 
print "ADDING INFOITEMS"
61
 
 
62
 
if info.data:
63
 
 
64
 
    for i,j in info.data.iteritems():
65
 
        for z in j:
66
 
            print i, z
67
 
            try:
68
 
                db.execute(""" INSERT INTO infoitems(item, description, \
69
 
userhost, time) VALUES(%s, %s, %s, %s)  """, (i, z, '', 0))
70
 
            except Exception, ex:
71
 
                print ex            
72
 
 
73
 
print "ADDING KARMA"
74
 
 
75
 
from gozerplugs.plugs.karma import Karma
76
 
k = Karma(datadir)
77
 
 
78
 
if k.karma:
79
 
 
80
 
    for i,j in k.karma.iteritems():
81
 
        print i, j
82
 
        try:
83
 
            db.execute(""" INSERT INTO karma(item, value) VALUES(%s, %s)  """, \
84
 
(i, j))
85
 
        except Exception, ex:
86
 
            print ex            
87
 
 
88
 
for i,j in k.reasonup.iteritems():
89
 
    for z in j:
90
 
        print i, z
91
 
        try:
92
 
            db.execute(""" INSERT INTO whykarma(item, updown, why) \
93
 
VALUES(%s, %s, %s)  """, (i, 'up', z))
94
 
        except Exception, ex:
95
 
            print ex            
96
 
 
97
 
for i,j in k.reasondown.iteritems():
98
 
    for z in j:
99
 
        print i, z
100
 
        try:
101
 
            db.execute(""" INSERT INTO whykarma(item, updown, why) \
102
 
VALUES(%s, %s, %s)  """, (i, 'down', z))
103
 
        except Exception, ex:
104
 
            print ex            
105
 
 
106
 
for i,j in k.whodown.iteritems():
107
 
    for z in j:
108
 
        print i, z
109
 
        try:
110
 
            db.execute(""" INSERT INTO whokarma(item, nick, updown) \
111
 
VALUES(%s, %s, %s)  """, (i, z, 'down'))
112
 
        except Exception, ex:
113
 
            print ex            
114
 
 
115
 
for i,j in k.whoup.iteritems():
116
 
    for z in j:
117
 
        print i, z
118
 
        try:
119
 
            db.execute(""" INSERT INTO whokarma(item, nick, updown) \
120
 
VALUES(%s, %s, %s)  """, (i, z, 'up'))
121
 
        except Exception, ex:
122
 
            print ex            
123
 
 
124
 
print "ADDING QUOTES"
125
 
 
126
 
from gozerplugs.plugs.quote import Quotes
127
 
q = Quotes(datadir + os.sep + 'quotes')
128
 
 
129
 
for i in q.data:
130
 
    print i.txt, i.nick, i.userhost, i.time
131
 
    try:
132
 
        db.execute(""" INSERT INTO quotes(quote, userhost, createtime, \
133
 
nick) VALUES (%s, %s, %s, %s) """, (i.txt, i.userhost, i.time, i.nick))
134
 
    except Exception, ex:
135
 
        print ex            
136
 
 
137
 
print "ADDING TODO"
138
 
 
139
 
from gozerplugs.plugs.todo import Todo
140
 
todo = Todo(datadir + os.sep + 'todo')
141
 
 
142
 
if todo.data:
143
 
 
144
 
    for i, j in todo.data.iteritems():
145
 
        for z in j:
146
 
            print i, z
147
 
            try:
148
 
                db.execute(""" INSERT INTO todo(name, time, duration, \
149
 
warnsec, descr, priority) VALUES(%s, %s, %s, %s, %s, %s) """, \
150
 
(z.name, z.time, z.duration, z.warnsec, z.descr, z.priority))
151
 
            except Exception, ex:
152
 
                print ex            
153
 
 
154
 
print 'ADDING LISTS'
155
 
 
156
 
from gozerbot.persist import Persist
157
 
mylists = Persist(datadir + os.sep + 'mylists')
158
 
 
159
 
if mylists.data:
160
 
 
161
 
    for i, j in mylists.data.iteritems(): 
162
 
        for z, zz in j.iteritems():
163
 
            for x in zz:
164
 
                print i, z, x
165
 
                try:
166
 
                    db.execute(""" INSERT INTO list(username, listname, item) \
167
 
VALUES(%s, %s, %s) """, (i, z, x))
168
 
                except Exception, ex:
169
 
                    print ex            
170
 
 
171
 
 
172
 
from gozerbot.pdol import Pdol
173
 
lists = Pdol(datadir + os.sep + 'lists')
174
 
 
175
 
if lists.data:
176
 
 
177
 
    for i, j in lists.data.iteritems(): 
178
 
        for z in j:
179
 
            print i, z
180
 
            try:
181
 
                db.execute(""" INSERT INTO list(username, listname, item) \
182
 
VALUES(%s, %s, %s) """, ('all', i, z))
183
 
            except Exception, ex:
184
 
                print ex            
185
 
 
186
 
print "DONE"