print -> print()
This commit is contained in:
parent
f67f063769
commit
e71188a6fa
|
@ -159,7 +159,7 @@ class CommandWindow:
|
|||
return self.stage_adhoc_commands_window_delete_event(self.window)
|
||||
|
||||
def __del__(self):
|
||||
print 'Object has been deleted.'
|
||||
print('Object has been deleted.')
|
||||
|
||||
# stage 1: waiting for command list
|
||||
def stage1(self):
|
||||
|
|
|
@ -36,7 +36,7 @@ from common import jingle_xtls
|
|||
import sqlite3 as sqlite
|
||||
|
||||
def create_log_db():
|
||||
print _('creating logs database')
|
||||
print(_('creating logs database'))
|
||||
con = sqlite.connect(logger.LOG_DB_PATH)
|
||||
os.chmod(logger.LOG_DB_PATH, 0600) # rw only for us
|
||||
cur = con.cursor()
|
||||
|
@ -84,7 +84,7 @@ def create_log_db():
|
|||
con.close()
|
||||
|
||||
def create_cache_db():
|
||||
print _('creating cache database')
|
||||
print(_('creating cache database'))
|
||||
con = sqlite.connect(logger.CACHE_DB_PATH)
|
||||
os.chmod(logger.CACHE_DB_PATH, 0600) # rw only for us
|
||||
cur = con.cursor()
|
||||
|
@ -128,7 +128,7 @@ def create_cache_db():
|
|||
con.close()
|
||||
|
||||
def split_db():
|
||||
print 'spliting database'
|
||||
print('spliting database')
|
||||
if os.name == 'nt':
|
||||
try:
|
||||
import configpaths
|
||||
|
@ -162,8 +162,8 @@ def split_db():
|
|||
cur.executescript('DROP TABLE %s;' % table)
|
||||
con.commit()
|
||||
except sqlite.OperationalError, e:
|
||||
print >> sys.stderr, 'error moving table %s to cache.db: %s' % \
|
||||
(table, str(e))
|
||||
print('error moving table %s to cache.db: %s' % (table, str(e)),
|
||||
file=sys.stderr)
|
||||
con.close()
|
||||
logger.CACHE_DB_PATH = tmp
|
||||
|
||||
|
@ -249,7 +249,7 @@ def check_and_possibly_move_config():
|
|||
continue
|
||||
if not os.path.exists(src):
|
||||
continue
|
||||
print 'moving %s to %s' % (src, dst)
|
||||
print(_('moving %s to %s') % (src, dst))
|
||||
shutil.move(src, dst)
|
||||
gajim.logger.init_vars()
|
||||
gajim.logger.attach_cache_database()
|
||||
|
@ -275,57 +275,57 @@ def check_and_possibly_create_paths():
|
|||
if not os.path.exists(MY_DATA):
|
||||
create_path(MY_DATA)
|
||||
elif os.path.isfile(MY_DATA):
|
||||
print _('%s is a file but it should be a directory') % MY_DATA
|
||||
print _('Gajim will now exit')
|
||||
print(_('%s is a file but it should be a directory') % MY_DATA)
|
||||
print(_('Gajim will now exit'))
|
||||
sys.exit()
|
||||
|
||||
if not os.path.exists(MY_CONFIG):
|
||||
create_path(MY_CONFIG)
|
||||
elif os.path.isfile(MY_CONFIG):
|
||||
print _('%s is a file but it should be a directory') % MY_CONFIG
|
||||
print _('Gajim will now exit')
|
||||
print(_('%s is a file but it should be a directory') % MY_CONFIG)
|
||||
print(_('Gajim will now exit'))
|
||||
sys.exit()
|
||||
|
||||
if not os.path.exists(MY_CACHE):
|
||||
create_path(MY_CACHE)
|
||||
elif os.path.isfile(MY_CACHE):
|
||||
print _('%s is a file but it should be a directory') % MY_CACHE
|
||||
print _('Gajim will now exit')
|
||||
print(_('%s is a file but it should be a directory') % MY_CACHE)
|
||||
print(_('Gajim will now exit'))
|
||||
sys.exit()
|
||||
|
||||
if not os.path.exists(VCARD_PATH):
|
||||
create_path(VCARD_PATH)
|
||||
elif os.path.isfile(VCARD_PATH):
|
||||
print _('%s is a file but it should be a directory') % VCARD_PATH
|
||||
print _('Gajim will now exit')
|
||||
print(_('%s is a file but it should be a directory') % VCARD_PATH)
|
||||
print(_('Gajim will now exit'))
|
||||
sys.exit()
|
||||
|
||||
if not os.path.exists(AVATAR_PATH):
|
||||
create_path(AVATAR_PATH)
|
||||
elif os.path.isfile(AVATAR_PATH):
|
||||
print _('%s is a file but it should be a directory') % AVATAR_PATH
|
||||
print _('Gajim will now exit')
|
||||
print(_('%s is a file but it should be a directory') % AVATAR_PATH)
|
||||
print(_('Gajim will now exit'))
|
||||
sys.exit()
|
||||
|
||||
if not os.path.exists(LOG_DB_FOLDER):
|
||||
create_path(LOG_DB_FOLDER)
|
||||
elif os.path.isfile(LOG_DB_FOLDER):
|
||||
print _('%s is a file but it should be a directory') % LOG_DB_FOLDER
|
||||
print _('Gajim will now exit')
|
||||
print(_('%s is a file but it should be a directory') % LOG_DB_FOLDER)
|
||||
print(_('Gajim will now exit'))
|
||||
sys.exit()
|
||||
|
||||
if not os.path.exists(PLUGINS_CONFIG_PATH):
|
||||
create_path(PLUGINS_CONFIG_PATH)
|
||||
elif os.path.isfile(PLUGINS_CONFIG_PATH):
|
||||
print _('%s is a file but it should be a directory') % PLUGINS_CONFIG_PATH
|
||||
print _('Gajim will now exit')
|
||||
print(_('%s is a file but it should be a directory') % PLUGINS_CONFIG_PATH)
|
||||
print(_('Gajim will now exit'))
|
||||
sys.exit()
|
||||
|
||||
if not os.path.exists(CACHE_DB_FOLDER):
|
||||
create_path(CACHE_DB_FOLDER)
|
||||
elif os.path.isfile(CACHE_DB_FOLDER):
|
||||
print _('%s is a file but it should be a directory') % CACHE_DB_FOLDER
|
||||
print _('Gajim will now exit')
|
||||
print(_('%s is a file but it should be a directory') % CACHE_DB_FOLDER)
|
||||
print(_('Gajim will now exit'))
|
||||
sys.exit()
|
||||
|
||||
check_and_possibly_move_config()
|
||||
|
@ -334,16 +334,16 @@ def check_and_possibly_create_paths():
|
|||
create_log_db()
|
||||
gajim.logger.init_vars()
|
||||
elif os.path.isdir(LOG_DB_PATH):
|
||||
print _('%s is a directory but should be a file') % LOG_DB_PATH
|
||||
print _('Gajim will now exit')
|
||||
print(_('%s is a directory but should be a file') % LOG_DB_PATH)
|
||||
print(_('Gajim will now exit'))
|
||||
sys.exit()
|
||||
|
||||
if not os.path.exists(CACHE_DB_PATH):
|
||||
create_cache_db()
|
||||
gajim.logger.attach_cache_database()
|
||||
elif os.path.isdir(CACHE_DB_PATH):
|
||||
print _('%s is a directory but should be a file') % CACHE_DB_PATH
|
||||
print _('Gajim will now exit')
|
||||
print(_('%s is a directory but should be a file') % CACHE_DB_PATH)
|
||||
print(_('Gajim will now exit'))
|
||||
sys.exit()
|
||||
|
||||
if not os.path.exists(XTLS_CERTS):
|
||||
|
@ -363,5 +363,5 @@ def create_path(directory):
|
|||
create_path(head)
|
||||
if os.path.exists(directory):
|
||||
return
|
||||
print _('creating %s directory') % directory
|
||||
print(('creating %s directory') % directory)
|
||||
os.mkdir(directory, 0700)
|
||||
|
|
|
@ -162,8 +162,8 @@ class ConfigPaths:
|
|||
try:
|
||||
self.add('TMP', None, fse(tempfile.gettempdir()))
|
||||
except IOError, e:
|
||||
print >> sys.stderr, 'Error opening tmp folder: %s\nUsing %s' % (
|
||||
str(e), os.path.expanduser('~'))
|
||||
print('Error opening tmp folder: %s\nUsing %s' % (str(e),
|
||||
os.path.expanduser('~')), file=sys.stderr)
|
||||
self.add('TMP', None, fse(os.path.expanduser('~')))
|
||||
|
||||
try:
|
||||
|
|
|
@ -593,7 +593,7 @@ class ConnectionVcard:
|
|||
|
||||
elif self.awaiting_answers[id_][0] == ARCHIVING_COLLECTIONS_ARRIVED:
|
||||
# TODO
|
||||
print 'ARCHIVING_COLLECTIONS_ARRIVED'
|
||||
print('ARCHIVING_COLLECTIONS_ARRIVED')
|
||||
|
||||
elif self.awaiting_answers[id_][0] == ARCHIVING_COLLECTION_ARRIVED:
|
||||
def save_if_not_exists(with_, nick, direction, tim, payload):
|
||||
|
@ -603,7 +603,7 @@ class ConnectionVcard:
|
|||
gajim.logger.save_if_not_exists(with_, direction, tim,
|
||||
msg=payload[0].getData(), nick=nick)
|
||||
elif payload[0].getName() == 'message':
|
||||
print 'Not implemented'
|
||||
print('Not implemented')
|
||||
chat = iq_obj.getTag('chat')
|
||||
if chat:
|
||||
with_ = chat.getAttr('with')
|
||||
|
|
|
@ -366,10 +366,10 @@ class RosterReceivedEvent(nec.NetworkIncomingEvent):
|
|||
try:
|
||||
j = helpers.parse_jid(jid)
|
||||
except Exception:
|
||||
print >> sys.stderr, _('JID %s is not RFC compliant. It '
|
||||
'will not be added to your roster. Use roster '
|
||||
'management tools such as '
|
||||
'http://jru.jabberstudio.org/ to remove it') % jid
|
||||
print(_('JID %s is not RFC compliant. It will not be added '
|
||||
'to your roster. Use roster management tools such as '
|
||||
'http://jru.jabberstudio.org/ to remove it') % jid,
|
||||
file=sys.stderr)
|
||||
else:
|
||||
infos = raw_roster[jid]
|
||||
if jid != our_jid and (not infos['subscription'] or \
|
||||
|
|
|
@ -38,8 +38,8 @@ try:
|
|||
except ImportError:
|
||||
supported = False
|
||||
if not os.name == 'nt': # only say that to non Windows users
|
||||
print _('D-Bus python bindings are missing in this computer')
|
||||
print _('D-Bus capabilities of Gajim cannot be used')
|
||||
print(_('D-Bus python bindings are missing in this computer'))
|
||||
print(_('D-Bus capabilities of Gajim cannot be used'))
|
||||
else:
|
||||
try:
|
||||
# test if dbus-x11 is installed
|
||||
|
@ -49,14 +49,14 @@ else:
|
|||
except dbus.DBusException:
|
||||
supported = False
|
||||
if not os.name == 'nt': # only say that to non Windows users
|
||||
print _('D-Bus does not run correctly on this machine')
|
||||
print _('D-Bus capabilities of Gajim cannot be used')
|
||||
print(_('D-Bus does not run correctly on this machine'))
|
||||
print(_('D-Bus capabilities of Gajim cannot be used'))
|
||||
except exceptions.SystemBusNotPresent:
|
||||
print _('D-Bus does not run correctly on this machine: system bus not '
|
||||
'present')
|
||||
print(_('D-Bus does not run correctly on this machine: system bus not '
|
||||
'present'))
|
||||
except exceptions.SessionBusNotPresent:
|
||||
print _('D-Bus does not run correctly on this machine: session bus not '
|
||||
'present')
|
||||
print(_('D-Bus does not run correctly on this machine: session bus not '
|
||||
'present'))
|
||||
|
||||
class SystemBus:
|
||||
"""
|
||||
|
|
|
@ -94,6 +94,6 @@ def close():
|
|||
if __name__ == '__main__':
|
||||
import time
|
||||
time.sleep(2.1)
|
||||
print getIdleSec()
|
||||
print(getIdleSec())
|
||||
close()
|
||||
print getIdleSec()
|
||||
print(getIdleSec())
|
||||
|
|
|
@ -401,7 +401,7 @@ class JingleTransportICEUDP(JingleTransport):
|
|||
if 'type' in candidate and candidate['type'] in types:
|
||||
cand.type = types[candidate['type']]
|
||||
else:
|
||||
print 'Unknown type %s', candidate['type']
|
||||
print('Unknown type %s' % candidate['type'])
|
||||
candidates.append(cand)
|
||||
self.remote_candidates.extend(candidates)
|
||||
return candidates
|
||||
|
|
|
@ -169,7 +169,7 @@ class Logger:
|
|||
try:
|
||||
self.con.commit()
|
||||
except sqlite.OperationalError, e:
|
||||
print >> sys.stderr, str(e)
|
||||
print(str(e), file=sys.stderr)
|
||||
self.commit_timout_id = None
|
||||
return False
|
||||
|
||||
|
@ -415,7 +415,7 @@ class Logger:
|
|||
self.con.commit()
|
||||
message_id = self.cur.lastrowid
|
||||
except sqlite.OperationalError, e:
|
||||
print >> sys.stderr, str(e)
|
||||
print(str(e), file=sys.stderr)
|
||||
else:
|
||||
self._timeout_commit()
|
||||
if message_id:
|
||||
|
|
|
@ -30,7 +30,7 @@ def parseLogLevel(arg):
|
|||
elif arg.isupper() and hasattr(logging, arg):
|
||||
return getattr(logging, arg)
|
||||
else:
|
||||
print _('%s is not a valid loglevel') % repr(arg)
|
||||
print(_('%s is not a valid loglevel') % repr(arg))
|
||||
return 0
|
||||
|
||||
def parseLogTarget(arg):
|
||||
|
@ -72,7 +72,7 @@ def parseAndSetLogLevels(arg):
|
|||
target = parseLogTarget(target.strip())
|
||||
if target:
|
||||
logging.getLogger(target).setLevel(level)
|
||||
print "Logger %s level set to %d" % (target, level)
|
||||
print("Logger %s level set to %d" % (target, level))
|
||||
|
||||
|
||||
class colors:
|
||||
|
|
|
@ -50,7 +50,7 @@ class DeviceManager(object):
|
|||
except ImportError:
|
||||
pass
|
||||
except gst.ElementNotFoundError:
|
||||
print 'element \'%s\' not found' % name
|
||||
print('element \'%s\' not found' % name)
|
||||
|
||||
|
||||
class AudioInputManager(DeviceManager):
|
||||
|
|
|
@ -50,7 +50,8 @@ class OptionsParser:
|
|||
except Exception:
|
||||
if os.path.exists(self.__filename):
|
||||
#we talk about a file
|
||||
print _('Error: cannot open %s for reading') % self.__filename
|
||||
print(_('Error: cannot open %s for reading') % self.__filename,
|
||||
file=sys.stderr)
|
||||
return False
|
||||
|
||||
new_version = gajim.config.get('version')
|
||||
|
@ -381,7 +382,7 @@ class OptionsParser:
|
|||
"""
|
||||
Apply indeces to the logs database
|
||||
"""
|
||||
print _('migrating logs database to indices')
|
||||
print(_('migrating logs database to indices'))
|
||||
# FIXME see #2812
|
||||
back = os.getcwd()
|
||||
os.chdir(logger.LOG_DB_FOLDER)
|
||||
|
|
|
@ -329,7 +329,7 @@ if __name__ == '__main__':
|
|||
global resolver
|
||||
host = text_view.get_text()
|
||||
def on_result(host, result_array):
|
||||
print 'Result:\n' + repr(result_array)
|
||||
print('Result:\n' + repr(result_array))
|
||||
resolver.resolve(host, on_result)
|
||||
win = Gtk.Window()
|
||||
win.set_border_width(6)
|
||||
|
|
|
@ -28,7 +28,7 @@ try:
|
|||
from docutils import nodes, utils
|
||||
from docutils.parsers.rst.roles import set_classes
|
||||
except ImportError:
|
||||
print "Requires docutils 0.4 for set_classes to be available"
|
||||
print("Requires docutils 0.4 for set_classes to be available")
|
||||
def create_xhtml(text):
|
||||
return None
|
||||
else:
|
||||
|
@ -147,7 +147,7 @@ else:
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print "test 1\n", Generator.create_xhtml("""
|
||||
print("test 1\n" + Generator.create_xhtml("""
|
||||
test::
|
||||
|
||||
>>> print 1
|
||||
|
@ -157,10 +157,10 @@ test::
|
|||
|
||||
this `` should trigger`` should trigger the problem.
|
||||
|
||||
""")
|
||||
print "test 2\n", Generator.create_xhtml("""
|
||||
"""))
|
||||
print("test 2\n" + Generator.create_xhtml("""
|
||||
*test1
|
||||
|
||||
test2_
|
||||
""")
|
||||
print "test 3\n", Generator.create_xhtml(""":ticket:`316` implements :xep:`71`""")
|
||||
"""))
|
||||
print("test 3\n" + Generator.create_xhtml(""":ticket:`316` implements :xep:`71`"""))
|
||||
|
|
|
@ -32,7 +32,6 @@ class Roster:
|
|||
self.setItem(val[zeroconf.C_NAME])
|
||||
|
||||
def getRoster(self):
|
||||
#print 'roster_zeroconf.py: getRoster'
|
||||
if self._data is None:
|
||||
self._data = {}
|
||||
self.update_roster()
|
||||
|
@ -50,11 +49,9 @@ class Roster:
|
|||
if key in self._data:
|
||||
if old_data[key] != self._data[key]:
|
||||
diffs[key] = self._data[key]['status']
|
||||
#print 'roster_zeroconf.py: diffs:' + str(diffs)
|
||||
return diffs
|
||||
|
||||
def setItem(self, jid, name='', groups=''):
|
||||
#print 'roster_zeroconf.py: setItem %s' % jid
|
||||
contact = self.zeroconf.get_contact(jid)
|
||||
if not contact:
|
||||
return
|
||||
|
@ -96,34 +93,27 @@ class Roster:
|
|||
self.setItem(jid=i['jid'], name=i['name'], groups=i['groups'])
|
||||
|
||||
def delItem(self, jid):
|
||||
#print 'roster_zeroconf.py: delItem %s' % jid
|
||||
if jid in self._data:
|
||||
del self._data[jid]
|
||||
|
||||
def getItem(self, jid):
|
||||
#print 'roster_zeroconf.py: getItem: %s' % jid
|
||||
if jid in self._data:
|
||||
return self._data[jid]
|
||||
|
||||
def __getitem__(self, jid):
|
||||
#print 'roster_zeroconf.py: __getitem__'
|
||||
return self._data[jid]
|
||||
|
||||
def getItems(self):
|
||||
#print 'roster_zeroconf.py: getItems'
|
||||
# Return list of all [bare] JIDs that the roster currently tracks.
|
||||
return self._data.keys()
|
||||
|
||||
def keys(self):
|
||||
#print 'roster_zeroconf.py: keys'
|
||||
return self._data.keys()
|
||||
|
||||
def getRaw(self):
|
||||
#print 'roster_zeroconf.py: getRaw'
|
||||
return self._data
|
||||
|
||||
def getResources(self, jid):
|
||||
#print 'roster_zeroconf.py: getResources(%s)' % jid
|
||||
return {}
|
||||
|
||||
def getGroups(self, jid):
|
||||
|
@ -142,14 +132,12 @@ class Roster:
|
|||
return self._data[jid]['txt_dict']['msg']
|
||||
|
||||
def getShow(self, jid):
|
||||
#print 'roster_zeroconf.py: getShow'
|
||||
return self.getStatus(jid)
|
||||
|
||||
def getPriority(self, jid):
|
||||
return 5
|
||||
|
||||
def getSubscription(self, jid):
|
||||
#print 'roster_zeroconf.py: getSubscription'
|
||||
return 'both'
|
||||
|
||||
def Subscribe(self, jid):
|
||||
|
|
|
@ -75,7 +75,7 @@ class DataFormWidget(Gtk.Alignment, object):
|
|||
selection.set_mode(Gtk.SelectionMode.MULTIPLE)
|
||||
|
||||
def on_data_form_vbox_key_press_event(self, widget, event):
|
||||
print 'key pressed'
|
||||
print('key pressed')
|
||||
|
||||
def set_data_form(self, dataform):
|
||||
"""
|
||||
|
|
|
@ -4812,7 +4812,6 @@ class AddSpecialNotificationDialog:
|
|||
if active == 1: # user selected 'choose sound'
|
||||
def on_ok(widget, path_to_snd_file):
|
||||
pass
|
||||
#print path_to_snd_file
|
||||
|
||||
def on_cancel(widget):
|
||||
widget.set_active(0) # go back to No Sound
|
||||
|
|
|
@ -42,7 +42,7 @@ except Exception:
|
|||
|
||||
def send_error(error_message):
|
||||
'''Writes error message to stderr and exits'''
|
||||
print >> sys.stderr, error_message.encode(PREFERRED_ENCODING)
|
||||
print(error_message.encode(PREFERRED_ENCODING), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
|
@ -52,7 +52,7 @@ try:
|
|||
# test if dbus-x11 is installed
|
||||
bus = dbus.SessionBus()
|
||||
except Exception:
|
||||
print _('D-Bus is not present on this machine or python module is missing')
|
||||
print(_('D-Bus is not present on this machine or python module is missing'))
|
||||
sys.exit(1)
|
||||
|
||||
OBJ_PATH = '/org/gajim/dbus/RemoteObject'
|
||||
|
@ -310,14 +310,15 @@ class GajimRemote:
|
|||
self.command = sys.argv[1]
|
||||
if self.command == 'help':
|
||||
if self.argv_len == 3:
|
||||
print self.help_on_command(sys.argv[2]).encode(PREFERRED_ENCODING)
|
||||
print(self.help_on_command(sys.argv[2]).encode(
|
||||
PREFERRED_ENCODING))
|
||||
else:
|
||||
print self.compose_help().encode(PREFERRED_ENCODING)
|
||||
print(self.compose_help().encode(PREFERRED_ENCODING))
|
||||
sys.exit(0)
|
||||
if self.command == 'handle_uri':
|
||||
self.handle_uri()
|
||||
if self.command == 'check_gajim_running':
|
||||
print self.check_gajim_running()
|
||||
print(self.check_gajim_running())
|
||||
sys.exit(0)
|
||||
self.init_connection()
|
||||
self.check_arguments()
|
||||
|
@ -354,27 +355,27 @@ class GajimRemote:
|
|||
if isinstance(res, list):
|
||||
for account in res:
|
||||
if isinstance(account, unicode):
|
||||
print account.encode(PREFERRED_ENCODING)
|
||||
print(account.encode(PREFERRED_ENCODING))
|
||||
else:
|
||||
print account
|
||||
print(account)
|
||||
elif self.command == 'account_info':
|
||||
if res:
|
||||
print self.print_info(0, res, True)
|
||||
print(self.print_info(0, res, True))
|
||||
elif self.command == 'list_contacts':
|
||||
for account_dict in res:
|
||||
print self.print_info(0, account_dict, True)
|
||||
print(self.print_info(0, account_dict, True))
|
||||
elif self.command == 'prefs_list':
|
||||
pref_keys = sorted(res.keys())
|
||||
for pref_key in pref_keys:
|
||||
result = '%s = %s' % (pref_key, res[pref_key])
|
||||
if isinstance(result, unicode):
|
||||
print result.encode(PREFERRED_ENCODING)
|
||||
print(result.encode(PREFERRED_ENCODING))
|
||||
else:
|
||||
print result
|
||||
print(result)
|
||||
elif self.command == 'contact_info':
|
||||
print self.print_info(0, res, True)
|
||||
print(self.print_info(0, res, True))
|
||||
elif res:
|
||||
print unicode(res).encode(PREFERRED_ENCODING)
|
||||
print(unicode(res).encode(PREFERRED_ENCODING))
|
||||
|
||||
def check_gajim_running(self):
|
||||
if not self.sbus:
|
||||
|
|
28
src/gajim.py
28
src/gajim.py
|
@ -42,7 +42,7 @@ import warnings
|
|||
if os.name == 'nt':
|
||||
log_path = os.path.join(os.environ['APPDATA'], 'Gajim')
|
||||
if not os.path.exists(log_path):
|
||||
os.mkdir(log_path, 0700)
|
||||
os.mkdir(log_path, 0o700)
|
||||
log_file = os.path.join(log_path, 'gajim.log')
|
||||
fout = open(log_file, 'a')
|
||||
sys.stdout = fout
|
||||
|
@ -65,7 +65,7 @@ if os.name == 'nt':
|
|||
try:
|
||||
import nbxmpp
|
||||
except ImportError:
|
||||
print 'Gajim needs python-nbxmpp to run. Quiting...'
|
||||
print('Gajim needs python-nbxmpp to run. Quiting...')
|
||||
sys.exit()
|
||||
|
||||
#from common import demandimport
|
||||
|
@ -131,15 +131,15 @@ def parseOpts():
|
|||
longargs += ' class= name= screen= gtk-module= sync g-fatal-warnings'
|
||||
longargs += ' sm-client-id= sm-client-state-file= sm-disable'
|
||||
opts = getopt.getopt(sys.argv[1:], shortargs, longargs.split())[0]
|
||||
except getopt.error, msg1:
|
||||
print msg1
|
||||
print 'for help use --help'
|
||||
except getopt.error as msg1:
|
||||
print(msg1)
|
||||
print('for help use --help')
|
||||
sys.exit(2)
|
||||
for o, a in opts:
|
||||
if o in ('-h', '--help'):
|
||||
print 'gajim [--help] [--quiet] [--verbose] ' + \
|
||||
print('gajim [--help] [--quiet] [--verbose] ' + \
|
||||
'[--loglevel subsystem=level[,subsystem=level[...]]] ' + \
|
||||
'[--profile name] [--config-path]'
|
||||
'[--profile name] [--config-path]')
|
||||
sys.exit()
|
||||
elif o in ('-q', '--quiet'):
|
||||
logging_helpers.set_quiet()
|
||||
|
@ -182,7 +182,7 @@ if os.name == 'nt':
|
|||
if self._file is None and self._error is None:
|
||||
try:
|
||||
self._file = open(fname, 'a')
|
||||
except Exception, details:
|
||||
except Exception as details:
|
||||
self._error = details
|
||||
if self._file is not None:
|
||||
self._file.write(text)
|
||||
|
@ -200,11 +200,11 @@ try:
|
|||
GObject.set_prgname('gajim')
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import Gdk
|
||||
except Warning, msg2:
|
||||
except Warning as msg2:
|
||||
if str(msg2) == 'could not open display':
|
||||
print >> sys.stderr, _('Gajim needs X server to run. Quiting...')
|
||||
print(_('Gajim needs X server to run. Quiting...'), file=sys.stderr)
|
||||
else:
|
||||
print >> sys.stderr, _('importing PyGTK failed: %s') % str(msg2)
|
||||
print(_('importing PyGTK failed: %s') % str(msg2), file=sys.stderr)
|
||||
sys.exit()
|
||||
warnings.resetwarnings()
|
||||
|
||||
|
@ -357,7 +357,7 @@ def pid_alive():
|
|||
|
||||
try:
|
||||
f1 = open('/proc/%d/cmdline'% pid)
|
||||
except IOError, e1:
|
||||
except IOError as e1:
|
||||
if e1.errno == errno.ENOENT:
|
||||
return False # file/pid does not exist
|
||||
raise
|
||||
|
@ -419,7 +419,7 @@ try:
|
|||
f2 = open(pid_filename, 'w')
|
||||
f2.write(str(os.getpid()))
|
||||
f2.close()
|
||||
except IOError, e2:
|
||||
except IOError as e2:
|
||||
dlg = dialogs.ErrorDialog(_('Disk Write Error'), str(e2))
|
||||
dlg.run()
|
||||
dlg.destroy()
|
||||
|
@ -464,4 +464,4 @@ if __name__ == '__main__':
|
|||
if os.name != 'nt':
|
||||
Gdk.threads_leave()
|
||||
except KeyboardInterrupt:
|
||||
print >> sys.stderr, 'KeyboardInterrupt'
|
||||
print('KeyboardInterrupt', file=sys.stderr)
|
||||
|
|
|
@ -198,8 +198,8 @@ def get_default_font():
|
|||
return line[start:line.find('"', start)].decode('utf-8')
|
||||
except Exception:
|
||||
#we talk about file
|
||||
print >> sys.stderr, _('Error: cannot open %s for reading') % \
|
||||
xfce_config_file
|
||||
print(_('Error: cannot open %s for reading') % xfce_config_file,
|
||||
file=sys.stderr)
|
||||
|
||||
elif os.path.exists(kde_config_file):
|
||||
try:
|
||||
|
@ -214,8 +214,8 @@ def get_default_font():
|
|||
return font_string.decode('utf-8')
|
||||
except Exception:
|
||||
#we talk about file
|
||||
print >> sys.stderr, _('Error: cannot open %s for reading') % \
|
||||
kde_config_file
|
||||
print(_('Error: cannot open %s for reading') % kde_config_file,
|
||||
file=sys.stderr)
|
||||
|
||||
return None
|
||||
|
||||
|
@ -343,10 +343,10 @@ def parse_server_xml(path_to_file):
|
|||
return handler.servers
|
||||
# handle exception if unable to open file
|
||||
except IOError, message:
|
||||
print >> sys.stderr, _('Error reading file:'), message
|
||||
print(_('Error reading file:') + message, file=sys.stderr)
|
||||
# handle exception parsing file
|
||||
except xml.sax.SAXParseException, message:
|
||||
print >> sys.stderr, _('Error parsing file:'), message
|
||||
print(_('Error parsing file:') + message, file=sys.stderr)
|
||||
|
||||
def set_unset_urgency_hint(window, unread_messages_no):
|
||||
"""
|
||||
|
@ -389,7 +389,7 @@ def get_abspath_for_script(scriptname, want_type = False):
|
|||
#we talk about a file here
|
||||
s = _('Could not write to %s. Session Management support will '
|
||||
'not work') % path_to_script
|
||||
print >> sys.stderr, s
|
||||
print(s, file=sys.stderr)
|
||||
|
||||
else: # normal user (not svn user)
|
||||
type_ = 'install'
|
||||
|
|
|
@ -2446,7 +2446,7 @@ class Interface:
|
|||
def save_config(self):
|
||||
err_str = parser.write()
|
||||
if err_str is not None:
|
||||
print >> sys.stderr, err_str
|
||||
print(err_str, file=sys.stderr)
|
||||
# it is good to notify the user
|
||||
# in case he or she cannot see the output of the console
|
||||
dialogs.ErrorDialog(_('Could not save your settings and '
|
||||
|
@ -2608,7 +2608,7 @@ class Interface:
|
|||
try:
|
||||
from ipython_view import IPythonView
|
||||
except ImportError:
|
||||
print 'ipython_view not found'
|
||||
print('ipython_view not found')
|
||||
return
|
||||
from gi.repository import Pango
|
||||
|
||||
|
|
|
@ -309,11 +309,11 @@ class IterableIPShell:
|
|||
@param header: Header to be printed before output
|
||||
@type header: string
|
||||
"""
|
||||
if verbose or debug: print header+cmd
|
||||
if verbose or debug: print(header+cmd)
|
||||
# flush stdout so we don't mangle python's buffering
|
||||
if not debug:
|
||||
input_, output = os.popen4(cmd)
|
||||
print output.read()
|
||||
print(output.read())
|
||||
output.close()
|
||||
input_.close()
|
||||
|
||||
|
|
|
@ -290,14 +290,14 @@ class MusicTrackListener(GObject.GObject):
|
|||
if __name__ == '__main__':
|
||||
def music_track_change_cb(listener, music_track_info):
|
||||
if music_track_info is None:
|
||||
print 'Stop!'
|
||||
print('Stop!')
|
||||
else:
|
||||
print music_track_info.title
|
||||
print(music_track_info.title)
|
||||
listener = MusicTrackListener.get()
|
||||
listener.connect('music-track-changed', music_track_change_cb)
|
||||
track = listener.get_playing_track()
|
||||
if track is None:
|
||||
print 'Now not playing anything'
|
||||
print('Now not playing anything')
|
||||
else:
|
||||
print 'Now playing: "%s" by %s' % (track.title, track.artist)
|
||||
print('Now playing: "%s" by %s' % (track.title, track.artist))
|
||||
GObject.MainLoop().run()
|
||||
|
|
|
@ -46,7 +46,7 @@ class TestResolver(unittest.TestCase):
|
|||
def testLibAsyncNSResolver(self):
|
||||
self._reset()
|
||||
if not resolver.USE_LIBASYNCNS:
|
||||
print 'testLibAsyncResolver: libasyncns-python not installed'
|
||||
print('testLibAsyncResolver: libasyncns-python not installed')
|
||||
return
|
||||
self.resolver = resolver.LibAsyncNSResolver()
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ class TestNonBlockingClient(unittest.TestCase):
|
|||
self.assert_(self.connection.con)
|
||||
features = self.client.Dispatcher.Stream.features
|
||||
if not features.getTag('auth'):
|
||||
print "Server doesn't support old authentication type, ignoring test"
|
||||
print("Server doesn't support old authentication type, ignoring test")
|
||||
else:
|
||||
self.assert_(self.connection.auth=='old_auth',
|
||||
msg='Unable to auth via old_auth')
|
||||
|
|
|
@ -18,12 +18,12 @@ try:
|
|||
longargs = 'help no-x verbose='
|
||||
opts, args = getopt.getopt(sys.argv[1:], shortargs, longargs.split())
|
||||
except getopt.error, msg:
|
||||
print msg
|
||||
print 'for help use --help'
|
||||
print(msg)
|
||||
print('for help use --help')
|
||||
sys.exit(2)
|
||||
for o, a in opts:
|
||||
if o in ('-h', '--help'):
|
||||
print 'runtests [--help] [--no-x] [--verbose level]'
|
||||
print('runtests [--help] [--no-x] [--verbose level]')
|
||||
sys.exit()
|
||||
elif o in ('-n', '--no-x'):
|
||||
use_x = False
|
||||
|
@ -31,7 +31,7 @@ for o, a in opts:
|
|||
try:
|
||||
verbose = int(a)
|
||||
except Exception:
|
||||
print 'verbose must be a number >= 0'
|
||||
print('verbose must be a number >= 0')
|
||||
sys.exit(2)
|
||||
|
||||
# new test modules need to be added manually
|
||||
|
|
|
@ -16,10 +16,10 @@ from common import jingle_xtls
|
|||
class fake_sock(Mock):
|
||||
def __init__(self, sockobj):
|
||||
Mock.__init__(self)
|
||||
|
||||
|
||||
self.sockobj = sockobj
|
||||
|
||||
|
||||
|
||||
|
||||
def setup_stream(self):
|
||||
sha1 = self.sockobj._get_sha1_auth()
|
||||
|
||||
|
@ -36,29 +36,29 @@ class fake_sock(Mock):
|
|||
def switch_stream(self):
|
||||
# Roles are reversed, client will be expecting server stream
|
||||
# and server will be expecting client stream
|
||||
|
||||
|
||||
temp = self.incoming
|
||||
self.incoming = self.outgoing
|
||||
self.outgoing = temp
|
||||
|
||||
def _recv(self, foo):
|
||||
return self.incoming.pop(0)
|
||||
|
||||
|
||||
def _send(self, data):
|
||||
# This method is surrounded by a try block,
|
||||
# This method is surrounded by a try block,
|
||||
# we can't use assert here
|
||||
|
||||
|
||||
if data != self.outgoing[0]:
|
||||
print 'FAILED SENDING TEST'
|
||||
print('FAILED SENDING TEST')
|
||||
self.outgoing.pop(0)
|
||||
|
||||
class fake_idlequeue(Mock):
|
||||
|
||||
def __init__(self):
|
||||
Mock.__init__(self)
|
||||
|
||||
Mock.__init__(self)
|
||||
|
||||
def plug_idle(self, obj, writable=True, readable=True):
|
||||
|
||||
|
||||
if readable:
|
||||
obj.pollin()
|
||||
if writable:
|
||||
|
@ -77,7 +77,7 @@ class TestSocks5(unittest.TestCase):
|
|||
queue.file_props = {}
|
||||
#self.sockobj = Socks5Receiver(fake_idlequeue(), streamhost, None)
|
||||
self.sockobj = Socks5Sender(fake_idlequeue(), None, 'server', Mock() ,
|
||||
None, None, True, file_props={})
|
||||
None, None, True, file_props={})
|
||||
sock = fake_sock(self.sockobj)
|
||||
self.sockobj._sock = sock
|
||||
self.sockobj._recv = sock._recv
|
||||
|
@ -85,70 +85,70 @@ class TestSocks5(unittest.TestCase):
|
|||
self.sockobj.state = 1
|
||||
self.sockobj.connected = True
|
||||
self.sockobj.pollend = self._pollend
|
||||
|
||||
|
||||
# Something that the receiver needs
|
||||
#self.sockobj.file_props['type'] = 'r'
|
||||
|
||||
|
||||
# Something that the sender needs
|
||||
self.sockobj.file_props = {}
|
||||
self.sockobj.file_props['type'] = 'r'
|
||||
self.sockobj.file_props['paused'] = ''
|
||||
self.sockobj.queue = Mock()
|
||||
self.sockobj.queue.process_result = self._pollend
|
||||
|
||||
|
||||
def _pollend(self, foo = None, duu = None):
|
||||
# This is a disconnect function
|
||||
sys.exit("end of the road")
|
||||
|
||||
def _check_inout(self):
|
||||
# Check if there isn't anything else to receive or send
|
||||
sock = self.sockobj._sock
|
||||
sock = self.sockobj._sock
|
||||
assert(sock.incoming == [])
|
||||
assert(sock.outgoing == [])
|
||||
|
||||
|
||||
def test_connection_server(self):
|
||||
return
|
||||
mocksock = self.sockobj._sock
|
||||
mocksock.setup_stream()
|
||||
#self.sockobj._sock.switch_stream()
|
||||
#self.sockobj._sock.switch_stream()
|
||||
s = socket.socket(2, 1, 6)
|
||||
server = ('127.0.0.1', 28000)
|
||||
|
||||
s.connect(server)
|
||||
|
||||
s.send(mocksock.outgoing.pop(0))
|
||||
self.assertEquals(s.recv(64), mocksock.incoming.pop(0))
|
||||
|
||||
|
||||
s.send(mocksock.outgoing.pop(0))
|
||||
self.assertEquals(s.recv(64), mocksock.incoming.pop(0))
|
||||
|
||||
|
||||
s.send(mocksock.outgoing.pop(0))
|
||||
self.assertEquals(s.recv(64), mocksock.incoming.pop(0))
|
||||
|
||||
def test_connection_client(self):
|
||||
|
||||
|
||||
|
||||
|
||||
mocksock = self.sockobj._sock
|
||||
mocksock.setup_stream()
|
||||
mocksock.switch_stream()
|
||||
mocksock.switch_stream()
|
||||
s = socket.socket(10, 1, 6)
|
||||
|
||||
|
||||
|
||||
|
||||
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
s.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
|
||||
s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
||||
|
||||
|
||||
netadd = ('::', 28000, 0, 0)
|
||||
s.bind(netadd)
|
||||
s.listen(socket.SOMAXCONN)
|
||||
(s, address) = s.accept()
|
||||
|
||||
|
||||
self.assertEquals(s.recv(64), mocksock.incoming.pop(0))
|
||||
|
||||
|
||||
self.assertEquals(s.recv(64), mocksock.incoming.pop(0))
|
||||
s.send(mocksock.outgoing.pop(0))
|
||||
|
||||
|
||||
buff = s.recv(64)
|
||||
inco = mocksock.incoming.pop(0)
|
||||
#self.assertEquals(s.recv(64), mocksock.incoming.pop(0))
|
||||
s.send(mocksock.outgoing.pop(0))
|
||||
|
||||
|
||||
def test_client_negoc(self):
|
||||
return
|
||||
self.sockobj._sock.setup_stream()
|
||||
|
@ -156,22 +156,22 @@ class TestSocks5(unittest.TestCase):
|
|||
self.sockobj.pollout()
|
||||
except SystemExit:
|
||||
pass
|
||||
|
||||
self._check_inout()
|
||||
|
||||
|
||||
self._check_inout()
|
||||
|
||||
def test_server_negoc(self):
|
||||
return
|
||||
self.sockobj._sock.setup_stream()
|
||||
self.sockobj._sock.switch_stream()
|
||||
self.sockobj._sock.switch_stream()
|
||||
try:
|
||||
self.sockobj.idlequeue.plug_idle(self.sockobj, False, True)
|
||||
except SystemExit:
|
||||
pass
|
||||
self._check_inout()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in New Issue