Skip to content
This repository was archived by the owner on Apr 17, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/nodeforge/PluginManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ def loadModule(path, reload=False):
# This can be overriden by os.chdir(). But, maybe the seperation between plugins, and working data is fine.

# create the module
execfile(mod.__file__, mod.__dict__)
with open(mod.__file__) as in_file:
exec(in_file.read(), mod.__dict__)

# remove the directory to clean it up now that we are done.
sys.path.pop(0)
Expand Down
4 changes: 2 additions & 2 deletions src/nodeforge/PluginUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

"""
from Plugin import Plugin, Priority
import sys, imp, os
import sys, imp, os, types

def comparePlugin(x,y):
"""
Expand Down Expand Up @@ -79,4 +79,4 @@ class MyPlugin(Plugin):

"""
sys._getframe(1).f_locals.update({'main': classobj})
return classobj
return classobj
11 changes: 6 additions & 5 deletions src/nodeforge/cores/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Core file for TCP/IP Clients
"""
from __future__ import with_statement
from __future__ import print_function

import socket, sys

Expand Down Expand Up @@ -60,7 +61,7 @@ def buildProtocol(self, addr):
This is executed when a connection is successful.
"""

print '%s: Connected at %s' % (self, addr)
print('%s: Connected at %s' % (self, addr))

# this line is necessary because some plugins need to know what
# the protocol object is, which is only defined when
Expand All @@ -78,7 +79,7 @@ def _buildProtocolTrigger(self):
plugin.onConnect()

def clientConnectionFailed(self, connector, reason):
print 'Connection failed. Reason:', reason
print('Connection failed. Reason:', reason)

for plugin in self.plugins:
plugin.onConnectFailed(reason)
Expand All @@ -88,14 +89,14 @@ def clientConnectionLost(self, connector, reason):
Called when a connection is lost.
"""

print >> sys.stderr, '%s: Disconnected.' % self
print('%s: Disconnected.' % self, file=sys.stderr)

for plugin in self.plugins:
plugin.onDisconnect(reason)


def startedConnecting(self, connector):
print 'Started to connect.'
print('Started to connect.')


def lineReceived(self, msg):
Expand All @@ -107,7 +108,7 @@ def lineReceived(self, msg):
# I think this happens and should be ignored.
if len(msg) == 0: return

print msg
print(msg)

for each in self.plugins:
each.onData(msg)
Expand Down
2 changes: 1 addition & 1 deletion src/nodeforge/import2.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
def customimport(name, globals=None, locals=None, fromlist=None):
try:
mod = oldimport(name, globals, locals, fromlist)
except SystemError, e:
except SystemError as e:
# Get the module to save the import to.
# It should be saved as _self.
# This is defined in main.PluginManager.loadModule
Expand Down
30 changes: 18 additions & 12 deletions src/plugins/dc/IMDB Query v1.1/imdblib.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
# TV-Series Current Episode Lister 1.01
# Date: 2008/04/28
# Author: Amit.Belani@hotmail.com
Expand Down Expand Up @@ -33,6 +34,11 @@
from time import sleep, strptime
import locale

try:
xrange # Python 2
except NameError:
xrange = range # Python 3

# Set locale
# This is used for formatting numbers (particularly for grouping digits)
if locale.getdefaultlocale()!=(None,None):
Expand Down Expand Up @@ -73,7 +79,7 @@ def getEps(title,max_len=1024,debug=False):
break
except:
if attempt<max_attempts:
if debug: print 'An error occurred while attempting to retrieve search results for "%s". %s attempts were made.'%(title,attempt)+'\n'
if debug: print('An error occurred while attempting to retrieve search results for "%s". %s attempts were made.'%(title,attempt)+'\n')
sleep(attempt*2)
else:
return 'An error occurred while attempting to retrieve search results for "%s". %s attempts were made.'%(title,attempt)
Expand All @@ -89,7 +95,7 @@ def getEps(title,max_len=1024,debug=False):
# Get episodes
i.update(s,'episodes')
s_title=s['long imdb title']
if (not s.has_key('episodes')) or len(s['episodes'])==0: return 'Episode info is unavailable for %s.'%s_title
if ('episodes' not in s) or len(s['episodes'])==0: return 'Episode info is unavailable for %s.'%s_title
s=sortedEpisodes(s)
if len(s)==0: return 'Episode info is unavailable for %s.'%s_title

Expand All @@ -100,11 +106,11 @@ def getEps(title,max_len=1024,debug=False):
# Process date related info for episodes
date_today=date.today()
for ep_ind in xrange(len(s)):
if s[ep_ind].has_key('original air date'):
if 'original air date' in s[ep_ind]:
try:
s[ep_ind]['date']=strptime(s[ep_ind]['original air date'],'%d %B %Y')
except: pass
if s[ep_ind].has_key('date'):
if 'date' in s[ep_ind]:
s[ep_ind]['date']=date(*s[ep_ind]['date'][0:3])
s[ep_ind]['age']=(s[ep_ind]['date']-date_today).days # Age is date delta in days
if s[ep_ind]['age']<0:
Expand All @@ -117,9 +123,9 @@ def getEps(title,max_len=1024,debug=False):

# Print last 10 listed episodes (if debugging)
if debug:
print 'Last 10 listed episodes:\nS# Epi# Age Episode Title'
for e in s[:10]: print '%s %s %s %s'%(str(e['season']).zfill(2)[:2],str(e['episode']).zfill(4),e.has_key('age') and str(e['age']).zfill(5) or ' '*5,e['title'].encode('latin-1'))
print
print('Last 10 listed episodes:\nS# Epi# Age Episode Title')
for e in s[:10]: print('%s %s %s %s'%(str(e['season']).zfill(2)[:2],str(e['episode']).zfill(4),'age' in e and str(e['age']).zfill(5) or ' '*5,e['title'].encode('latin-1')))
print()

# Declare convenient functions for use in generating output string
def getSE(e):
Expand Down Expand Up @@ -155,15 +161,15 @@ def getDate(e): return 'i.e. on '+e['date'].strftime('%a, ')+str(e['date'].day)+
# Generate output string when next upcoming episode is available
e_out=e_out+'The next upcoming episode '+(e_out=='' and ('for '+s_title+' ') or '')+'is "'+e['title']+'"'+getSE(e)+'.'

if e.has_key('age'):
if 'age' in e:
e_schedule= e['age']>1 and ('in %s days'%getAge(e)) or e['age']==1 and 'tomorrow' or e['age']==0 and 'today'
e_out=e_out+' It airs '+e_schedule+', '+getDate(e)+'.'
del e_schedule
else:
e_out=e_out+' Its air date is unavailable.'

if include_plot:
if e.has_key('plot') and e['plot']!='Related Links':
if 'plot' in e and e['plot']!='Related Links':
e_out=e_out+' Its plot is: '+e['plot']
elif e_out.endswith('Its air date is unavailable.'):
e_out=e_out.replace('Its air date is unavailable.','Its air date and plot are unavailable.')
Expand Down Expand Up @@ -224,10 +230,10 @@ def getEps_test(add_noplot=False):
#titles=('',) # For testing a single or limited number of TV-series

for title in titles:
print title+':\n'
print getEps(title,debug=False)+'\n'+'_'*72+'\n'
print(title+':\n')
print(getEps(title,debug=False)+'\n'+'_'*72+'\n')
if add_noplot:
print title+': '+getEps(title+' /noplot',debug=False)++'\n''_'*72+'\n'
print(title+': '+getEps(title+' /noplot',debug=False)++'\n''_'*72+'\n')

# Run tests
#getEps_test()
7 changes: 4 additions & 3 deletions src/plugins/dc/NMDC Parser/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
from nodeforge.PluginUtils import *
from twisted.internet.task import LoopingCall

Expand Down Expand Up @@ -120,9 +121,9 @@ def send(self, string):

try:
self.core.sendLine(string)
print '>>> %s' % string
except Exception, e:
print e
print('>>> %s' % string)
except Exception as e:
print(e)

def tell(self, target, msg):
self.send('$To: %s From: %s $<%s> %s' % (target, self.nick, self.nick, msg))
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/dc/Party Tools/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def roll(self):
context.reply('Die must be between 1 and 500, ex. 5d24')
return

except Exception, e:
except Exception as e:
context.reply('Parse Error ex. 5d24')
return

Expand Down
3 changes: 2 additions & 1 deletion src/plugins/irc/IRC Parser/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
An IRC parser.
This is by no means complete.
"""
from __future__ import print_function

from nodeforge.PluginUtils import *
from twisted.internet.task import LoopingCall
Expand All @@ -17,7 +18,7 @@ def send(self, string):
string = string.encode('raw_unicode_escape')

self.core.sendLine(string)
print '>>> %s' % string
print('>>> %s' % string)

def privmsg(self, who, msg):
"""
Expand Down