Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Massive changes in the Plex

  • Loading branch information...
commit a94de8f072aa18ad76adcb2aa52c68ebc7907674 1 parent e64c2c5
@mpesce authored
View
4 inplex_google.py
@@ -183,10 +183,10 @@ def CreateVCard(self, entry):
# Create connections based on entry
connections = []
for an_email in entry["smtp"]: # Gosh, does this work?
- thingy = { "smtp": an_email }
+ thingy = { "type": "plexus-message", "service": "smtp", "credential": an_email } # New connection format
connections.append(thingy)
- vcard = { "vcard": [ { "fn": entry["name"], "plexus-type": "plexus-message", "connections": connections } ] }
+ vcard = { "vcard": [ { "fn": entry["name"], "connections": connections } ] }
return vcard
def SendToPlex(self, entry):
View
2  inplex_twitter.py
@@ -80,7 +80,7 @@ def get_my_screen_name(self):
def AddContacts(self, friend):
"""Adds a Twitter Friend to the Plex"""
- vcard = { "vcard": [ { "fn": friend.name, "plexus-type": "plexus-message", "connections": [{"twitter": friend.screen_name},] } ] }
+ vcard = { "vcard": [ { "fn": friend.name, "connections": [{"type": "plexus-message", "service": "twitter", "credential": friend.screen_name},] } ] }
print vcard
plx = plex.Plex()
plx.add_from_jcard(vcard)
View
6 plex.py
@@ -78,7 +78,7 @@ def connect(self):
# Do we know if we have the correct table in this database?
# Or any tables at all?
self.connector.execute('''create table if not exists graph (firstname text, lastname text, uid text, pluid text primary key)''')
- self.connector.execute('''create table if not exists connections (pluid text, type text, service text, info text)''')
+ self.connector.execute('''create table if not exists connections (pluid text, type text, service text, credential text)''')
return self.connector
except:
print('Some sort of exception connecting to plex')
@@ -127,7 +127,7 @@ def add_from_jcard(self, jcards):
# Now we need to add it to the plexbase
for jcard in jcards['vcard']:
name = jcard['fn']
- plexus_type = jcard['plexus-type']
+
# break the name into firstname and lastname components
fullname = name.split()
# is there a uid?
@@ -173,7 +173,7 @@ def add_from_jcard(self, jcards):
conlist = jcard['connections']
for connection in conlist:
print connection
- curs.execute('insert into connections values (?, ?, ?, ?)', (pluid, plexus_type, connection.items()[0][0], json.dumps(connection.items())))
+ curs.execute('insert into connections values (?, ?, ?, ?)', (pluid, connection['type'], connection['service'], connection['credential']))
print('New entry added to Plexbase.')
except KeyboardInterrupt:
print('Something did not work with that')
View
6 plex2vcard.py
@@ -31,7 +31,7 @@ def makevcard(first, last, uid, connections):
#print connections
con_list = []
for con in connections:
- mbr = { con[0][0]: con[0][1] }
+ mbr = { "type": con[0], "service": con[1], con[2][0][0]: con[2][0][1] }
con_list.append(mbr)
conpart = { "connections": con_list }
if (len(first) > 0):
@@ -72,8 +72,8 @@ def plex2vcards():
cons = []
friend_connections = curs.fetchall()
for each_connection in friend_connections:
- #print ' %s %s' % (each_connection[1], each_connection[2])
- cons.append(json.loads(each_connection[3]))
+ #print ' %s %s %s' % (each_connection[1], each_connection[2], each_connection[3])
+ cons.append([each_connection[1], each_connection[2], json.loads(each_connection[3])])
vcard = makevcard(friend_firstname, friend_lastname, friend_uid, cons)
#print vcard
if (len(retval) == 0):
View
21 sharer.py
@@ -149,9 +149,8 @@ def share(msgid, type, pluid, timestamp, data):
print 'No matching type for UPDATE, which is weird and PROBABLY VERY WRONG, aborting...'
return
else:
- for method in resultant:
- beam(msgid, type, pluid, timestamp, data, host, port, dest_id) # Should send things right along. Probably.
- return
+ beam(msgid, type, pluid, timestamp, data, host, port, dest_id) # Should send things right along. Probably.
+ return
if (type.find('plexus-message') == 0):
@@ -168,18 +167,18 @@ def share(msgid, type, pluid, timestamp, data):
if (len(resultant) > 0): # We has some matches, yay!
for connection in resultant:
- method = connection[2]
- credential = json.loads(connection[3])
- print 'method: %s credential: %s' % (method, credential)
+ service = connection[2]
+ credential = connection[3]
+ print ' type: %s service:%s credential: %s' % (type, service, credential)
# For the moment, we'll focus on Twitter. This should be modular, blah blah blah
- if (method.find('twitter') == 0):
+ if (service.find('twitter') == 0):
print 'Packing something off to Twitter'
old_data = json.loads(data) # Grab the old data
- print old_data
- print credential[0]
- print credential[0][1]
- plexus_data = { "service": "plexus", "plexus-message": old_data['plexus-message'], "destination": [credential[0][1],], "when": old_data['when'] }
+ #print old_data
+ #print credential[0]
+ #print credential[0][1]
+ plexus_data = { "service": "plexus", "plexus-message": old_data['plexus-message'], "destination": [credential,], "when": old_data['when'] }
new_plexus_data = json.dumps(plexus_data)
(host, port, dest_id) = share_map_from_type(type)
if (host == None):
Please sign in to comment.
Something went wrong with that request. Please try again.