-import ConfigParser
+import configparser
import copy
import logging
import logging.handlers
import sys
import time
import traceback
-import urlparse
+import urllib.parse
from benderjab import rpc
# We made sure source ends in a / earlier
cur_list = [ source+subdir for subdir in self.list_filter(stdout)]
entries.extend(cur_list)
- LOGGER.debug(u"Found the following: %s" % (unicode(entries)))
+ LOGGER.debug("Found the following: %s" % (str(entries)))
return entries
def list_filter(self, lines):
"""
dirs_to_copy = []
direntries = [ x[0:42].split() + [x[43:-1]] for x in lines ]
- LOGGER.debug(u'direntries: %s' % (unicode(direntries),))
+ LOGGER.debug('direntries: %s' % (str(direntries),))
for permissions, size, filedate, filetime, filename in direntries:
if permissions[0] == 'd':
# hey its a directory, the first step to being something we want to
return path roots that have finished.
"""
- for dir_key, proc_value in self.processes.items():
+ for dir_key, proc_value in list(self.processes.items()):
retcode = proc_value.poll()
if retcode is None:
# process hasn't finished yet
"""
Return list of current run folder names
"""
- return self.processes.keys()
+ return list(self.processes.keys())
class CopierBot(rpc.XmlRpcBot):
def __init__(self, section=None, configfile=None):
require_resource=True)
except bot.JIDMissingResource:
msg = 'need a full jabber ID + resource for xml-rpc destinations'
- print >>sys.stderr, msg
+ print(msg, file=sys.stderr)
raise bot.JIDMissingResource(msg)
def run(self):
start our copy
"""
# Note, args comes in over the network, so don't trust it.
- LOGGER.debug("Arguments to startCopy %s" % (unicode(args),))
+ LOGGER.debug("Arguments to startCopy %s" % (str(args),))
copy_urls = []
for a in args:
clean_url = self.validate_url(a)
"""
self.rsync.poll()
for p in self.pending:
- if p not in self.rsync.keys():
+ if p not in list(self.rsync.keys()):
self.reportSequencingFinished(p)
self.pending.remove(p)
"""
Parse xmpp chat messages
"""
- help = u"I can [copy], or report current [status]"
- if re.match(u"help", msg):
+ help = "I can [copy], or report current [status]"
+ if re.match("help", msg):
reply = help
elif re.match("copy", msg):
started = self.startCopy()
- reply = u"started copying " + ", ".join(started)
- elif re.match(u"status", msg):
- msg = [u"Currently %d rsync processes are running." % (len(self.rsync))]
- for d in self.rsync.keys():
- msg.append(u" " + d)
+ reply = "started copying " + ", ".join(started)
+ elif re.match("status", msg):
+ msg = ["Currently %d rsync processes are running." % (len(self.rsync))]
+ for d in list(self.rsync.keys()):
+ msg.append(" " + d)
reply = os.linesep.join(msg)
else:
- reply = u"I didn't understand '%s'" % (unicode(msg))
+ reply = "I didn't understand '%s'" % (str(msg))
return reply
def validate_url(self, url):
- user_url = urlparse.urlsplit(url)
+ user_url = urllib.parse.urlsplit(url)
user_scheme = user_url[0]
user_netloc = user_url[1]
user_path = user_url[2]
for source in self.sources:
- source_url = urlparse.urlsplit(source)
+ source_url = urllib.parse.urlsplit(source)
source_scheme = source_url[0]
source_netloc = source_url[1]
source_path = source_url[2]