This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2gobroker. commit e03923f69b4b21ff60a6fa825f479ffce8f68d26 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Thu Mar 26 14:48:50 2015 +0100 pyflakes cleanup --- setup.py | 2 ++ x2gobroker/authmechs/https_get_authmech.py | 7 +---- x2gobroker/authservice.py | 1 - x2gobroker/brokers/base_broker.py | 6 ++-- x2gobroker/client/plain.py | 4 +-- x2gobroker/defaults.py | 4 +-- x2gobroker/tests/test_broker_agent.py | 6 ++-- x2gobroker/tests/test_broker_inifile.py | 45 --------------------------- x2gobroker/tests/test_client_plain_base.py | 2 +- x2gobroker/tests/test_utils.py | 1 - x2gobroker/tests/test_web_plain_base.py | 2 +- x2gobroker/tests/test_web_plain_inifile.py | 6 ++-- x2gobroker/tests/test_web_plain_zeroconf.py | 2 +- x2gobroker/tests/test_web_uccs_zeroconf.py | 5 ++- x2gobroker/utils.py | 6 ++-- x2gobroker/web/extras.py | 2 -- x2gobroker/web/json.py | 3 +- x2gobroker/web/plain.py | 2 +- x2gobroker/web/uccs.py | 3 -- 19 files changed, 24 insertions(+), 85 deletions(-) diff --git a/setup.py b/setup.py index d83c902..49299d2 100755 --- a/setup.py +++ b/setup.py @@ -23,9 +23,11 @@ from setuptools import setup, find_packages import os +__VERSION__ = None for line in file(os.path.join('x2gobroker', '__init__.py')).readlines(): if (line.startswith('__VERSION__')): exec(line.strip()) +__AUTHOR__ = None for line in file(os.path.join('x2gobroker', '__init__.py')).readlines(): if (line.startswith('__AUTHOR__')): exec(line.strip()) diff --git a/x2gobroker/authmechs/https_get_authmech.py b/x2gobroker/authmechs/https_get_authmech.py index dc5a085..c4c2599 100644 --- a/x2gobroker/authmechs/https_get_authmech.py +++ b/x2gobroker/authmechs/https_get_authmech.py @@ -31,13 +31,8 @@ # attack. # modules -import sys import httplib import base64 -import string -import ConfigParser - -from x2gobroker.defaults import X2GOBROKER_CONFIG as _X2GOBROKER_CONFIG class X2GoBrokerAuthMech(object): @@ -60,7 +55,7 @@ class X2GoBrokerAuthMech(object): https = httplib.HTTPSConnection(host,port) https.putrequest("GET", path) https.putheader("Host", host) - https.putheader("User-Agent", "x2go http auth") + https.putheader("User-Agent", "X2Go Session Broker") https.putheader("Authorization", "Basic %s" % auth) https.endheaders() diff --git a/x2gobroker/authservice.py b/x2gobroker/authservice.py index 93e3e42..35f7171 100644 --- a/x2gobroker/authservice.py +++ b/x2gobroker/authservice.py @@ -18,7 +18,6 @@ # Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. -import os import socket # X2Go Session Broker modules diff --git a/x2gobroker/brokers/base_broker.py b/x2gobroker/brokers/base_broker.py index 189c679..f7fe912 100644 --- a/x2gobroker/brokers/base_broker.py +++ b/x2gobroker/brokers/base_broker.py @@ -483,6 +483,7 @@ class X2GoBroker(object): def _import_authmech_module(self, mech='pam'): try: if self.authmech_module is None: + _authmech_module = None exec("import x2gobroker.authmechs.{mech}_authmech as _authmech_module".format(mech=mech)) self.authmech_module = _authmech_module return True @@ -764,6 +765,7 @@ class X2GoBroker(object): def _import_nameservice_module(self, service='libnss'): try: if self.nameservice_module is None: + _nameservice_module = None exec("import x2gobroker.nameservices.{service}_nameservice as _nameservice_module".format(service=service)) self.nameservice_module = _nameservice_module return True @@ -1224,7 +1226,6 @@ class X2GoBroker(object): profile['rootless'] = False remote_agent = self.get_remote_agent(profile_id) - agent_query_mode = ( remote_agent == u'LOCAL') and u'LOCAL' or u'SSH' if self.check_for_sessions(profile_id): if remote_agent: try: @@ -1309,9 +1310,6 @@ class X2GoBroker(object): # try to retrieve contact to a remote broker agent remote_agent = self.get_remote_agent(profile_id) - if remote_agent: - agent_query_mode = ( remote_agent == u'LOCAL') and u'LOCAL' or u'SSH' - # check for already running sessions for the given user (if any is given) session_list = [] if remote_agent and username: diff --git a/x2gobroker/client/plain.py b/x2gobroker/client/plain.py index 4b0dece..d4cfd9c 100644 --- a/x2gobroker/client/plain.py +++ b/x2gobroker/client/plain.py @@ -25,7 +25,7 @@ import types # Python X2Go Broker modules import x2gobroker.defaults -from x2gobroker.loggers import logger_broker, logger_error +from x2gobroker.loggers import logger_broker def _override_do_authenticate(username='', password=''): return True @@ -55,8 +55,6 @@ class X2GoBrokerClient(object): if broker_backend.is_enabled(): - global_config = broker_backend.get_global_config() - if os.environ.has_key('SSH_CLIENT'): ip = os.environ['SSH_CLIENT'].split()[0] else: diff --git a/x2gobroker/defaults.py b/x2gobroker/defaults.py index a6d4830..382fac5 100644 --- a/x2gobroker/defaults.py +++ b/x2gobroker/defaults.py @@ -19,14 +19,12 @@ # modules import os -import sys import uuid -import getpass import socket import pwd, grp import logging -from loggers import logger_broker, logger_access, logger_error, PROG_NAME, X2GOBROKER_DAEMON_USER +from loggers import logger_broker, logger_access, logger_error, X2GOBROKER_DAEMON_USER from loggers import iniconfig_loaded if iniconfig_loaded: from loggers import iniconfig, iniconfig_section diff --git a/x2gobroker/tests/test_broker_agent.py b/x2gobroker/tests/test_broker_agent.py index 795ea94..2aaa252 100644 --- a/x2gobroker/tests/test_broker_agent.py +++ b/x2gobroker/tests/test_broker_agent.py @@ -19,7 +19,6 @@ import unittest import tempfile -import copy import time # Python X2GoBroker modules @@ -504,9 +503,12 @@ broker-portscan-x2goservers = true self.assertTrue ( remote_agent['hostaddr'] != 'downhost1.external') i += 1 + x2gobroker.agent._call_local_broker_agent = _save_local_broker_agent_call + x2gobroker.agent._call_remote_broker_agent = _save_remote_broker_agent_call + x2gobroker.utils.portscan = _save_portscan + def test_suite(): from unittest import TestSuite, makeSuite suite = TestSuite() suite.addTest(makeSuite(TestX2GoBrokerAgent)) return suite - diff --git a/x2gobroker/tests/test_broker_inifile.py b/x2gobroker/tests/test_broker_inifile.py index 4ebaf1a..27e48c9 100644 --- a/x2gobroker/tests/test_broker_inifile.py +++ b/x2gobroker/tests/test_broker_inifile.py @@ -91,51 +91,6 @@ command = GNOME for key in _profile.keys(): self.assertTrue( ( key in _expected_profile.keys() and _profile[key] == _expected_profile[key] ) ) - # TEST COMPLETION OF DEFAULTS FROM CODE IN defaults.py - - def test_getprofilecompletion(self): - _session_profiles = """ -[DEFAULT] -exports = -fullscreen = false -width = 800 -height = 600 -applications = TERMINAL, WWWBROWSER - -[testprofile] -user = foo -command = GNOME - -""" - tf = tempfile.NamedTemporaryFile() - print >> tf, _session_profiles - tf.seek(0) - inifile_backend = inifile.X2GoBroker(profile_config_file=tf.name) - _expected_defaults = copy.deepcopy(x2gobroker.defaults.X2GOBROKER_SESSIONPROFILE_DEFAULTS['DEFAULT']) - for key in copy.deepcopy(_expected_defaults).keys(): - if key.startswith('acl-'): - del _expected_defaults[key] - _expected_defaults.update( { - u'exports': '', - u'fullscreen': False, - u'width': 800, - u'height': 600, - u'applications': ['TERMINAL','WWWBROWSER',], - u'user': 'foo', - u'command': 'GNOME', - } ) - # just testing the directrdp hard-coded defaults - _expected_defaults.update( { - u'directrdp': False, - } ) - _expected_profile = copy.deepcopy(_expected_defaults) - _profile = inifile_backend.get_profile('testprofile') - for key in _expected_profile.keys(): - self.assertTrue( ( key in _profile.keys() ) ) - for key in _profile.keys(): - self.assertTrue( ( key in _expected_profile.keys() and _profile[key] == _expected_profile[key] ) ) - - ### TEST SESSION PROFILES: get_profile_defaults() def test_getprofiledefaults(self): diff --git a/x2gobroker/tests/test_client_plain_base.py b/x2gobroker/tests/test_client_plain_base.py index 432287c..6d72b30 100644 --- a/x2gobroker/tests/test_client_plain_base.py +++ b/x2gobroker/tests/test_client_plain_base.py @@ -24,7 +24,7 @@ import tempfile import x2gobroker.defaults import x2gobroker.client.plain -from nose.tools import * +from nose.tools import assert_equal, assert_true, assert_false class args(): def __init__(self): diff --git a/x2gobroker/tests/test_utils.py b/x2gobroker/tests/test_utils.py index b60d0dc..fc2b66c 100644 --- a/x2gobroker/tests/test_utils.py +++ b/x2gobroker/tests/test_utils.py @@ -18,7 +18,6 @@ # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. import unittest -import tempfile # Python X2GoBroker modules import x2gobroker.utils diff --git a/x2gobroker/tests/test_web_plain_base.py b/x2gobroker/tests/test_web_plain_base.py index 7a4c038..49676e3 100644 --- a/x2gobroker/tests/test_web_plain_base.py +++ b/x2gobroker/tests/test_web_plain_base.py @@ -20,7 +20,7 @@ import unittest import tempfile from paste.fixture import TestApp -from nose.tools import * +from nose.tools import assert_equal import tornado.wsgi # Python X2GoBroker modules diff --git a/x2gobroker/tests/test_web_plain_inifile.py b/x2gobroker/tests/test_web_plain_inifile.py index afa4eb1..68e6e64 100644 --- a/x2gobroker/tests/test_web_plain_inifile.py +++ b/x2gobroker/tests/test_web_plain_inifile.py @@ -18,9 +18,9 @@ # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. import unittest -import tempfile -from paste.fixture import TestApp -from nose.tools import * +#import tempfile +#from paste.fixture import TestApp +#from nose.tools import * import tornado.wsgi # Python X2GoBroker modules diff --git a/x2gobroker/tests/test_web_plain_zeroconf.py b/x2gobroker/tests/test_web_plain_zeroconf.py index f805aa4..0882b1a 100644 --- a/x2gobroker/tests/test_web_plain_zeroconf.py +++ b/x2gobroker/tests/test_web_plain_zeroconf.py @@ -20,7 +20,7 @@ import unittest import tempfile from paste.fixture import TestApp -from nose.tools import * +from nose.tools import assert_equal import tornado.wsgi # Python X2GoBroker modules diff --git a/x2gobroker/tests/test_web_uccs_zeroconf.py b/x2gobroker/tests/test_web_uccs_zeroconf.py index e1e5782..5492ef7 100644 --- a/x2gobroker/tests/test_web_uccs_zeroconf.py +++ b/x2gobroker/tests/test_web_uccs_zeroconf.py @@ -20,10 +20,9 @@ import unittest import tempfile from paste.fixture import TestApp -from nose.tools import * +from nose.tools import assert_equal import tornado.wsgi import json -import base64 # Python X2GoBroker modules import x2gobroker.defaults @@ -90,7 +89,7 @@ desktop-shell = KDE def test_suite(): - from unittest import TestSuite, makeSuite + from unittest import TestSuite#, makeSuite suite = TestSuite() #suite.addTest(makeSuite(TestX2GoBrokerWebUccsZeroConf)) return suite diff --git a/x2gobroker/utils.py b/x2gobroker/utils.py index efa4a80..4b00434 100644 --- a/x2gobroker/utils.py +++ b/x2gobroker/utils.py @@ -184,7 +184,7 @@ def drop_privileges(uid, gid): os.setuid(running_uid) # Ensure a very conservative umask - old_umask = os.umask(077) + os.umask(077) # set the new user's home directory as $HOME os.environ['HOME'] = pwd.getpwnam(uid).pw_dir @@ -254,11 +254,11 @@ def portscan(addr, port=22): """ ip_proto = 0 try: - dns_query = socket.getaddrinfo(addr, None, socket.AF_INET6) + socket.getaddrinfo(addr, None, socket.AF_INET6) ip_proto = 6 except socket.gaierror: try: - dns_query = socket.getaddrinfo(addr, None, socket.AF_INET) + socket.getaddrinfo(addr, None, socket.AF_INET) ip_proto = 4 except socket.gaierror: # we can't find a valid address for this host, so returning a failure... diff --git a/x2gobroker/web/extras.py b/x2gobroker/web/extras.py index 1e16907..a9fe3f9 100644 --- a/x2gobroker/web/extras.py +++ b/x2gobroker/web/extras.py @@ -47,8 +47,6 @@ class X2GoBrokerItWorks(_RequestHandler): def get(self, *args, **kwargs): - output = "" - self.write('<body><html>') self.write('<h1>X2Go Session Broker</h1>') self.write('<p>It works...</p>') diff --git a/x2gobroker/web/json.py b/x2gobroker/web/json.py index 1288928..96b1fd7 100644 --- a/x2gobroker/web/json.py +++ b/x2gobroker/web/json.py @@ -17,7 +17,6 @@ # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. # modules -import types import tornado.web from tornado.escape import native_str, parse_qs_bytes @@ -111,7 +110,7 @@ class X2GoBrokerWeb(_RequestHandler): pubkey = self.get_argument('pubkey', default='') task = self.get_argument('task', default='') profile_id = self.get_argument('profile-id', default='') - new_password = self.get_argument('newpass', default='') + #new_password = self.get_argument('newpass', default='') # compat stuff if task == 'listsessions': task = 'listprofiles' diff --git a/x2gobroker/web/plain.py b/x2gobroker/web/plain.py index 591fbc9..d870489 100644 --- a/x2gobroker/web/plain.py +++ b/x2gobroker/web/plain.py @@ -107,7 +107,7 @@ class X2GoBrokerWeb(_RequestHandler): pubkey = self.get_argument('pubkey', default='') task = self.get_argument('task', default='') profile_id = self.get_argument('sid', default='') - new_password = self.get_argument('newpass', default='') + #new_password = self.get_argument('newpass', default='') output = '' diff --git a/x2gobroker/web/uccs.py b/x2gobroker/web/uccs.py index 7a6dc8c..92686f8 100644 --- a/x2gobroker/web/uccs.py +++ b/x2gobroker/web/uccs.py @@ -17,8 +17,6 @@ # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. # modules -import re -import base64 import datetime import types import random @@ -133,7 +131,6 @@ class X2GoBrokerWebAPI(tornado.web.RequestHandler): except KeyError: raise tornado.web.HTTPError(401) - cookie = '' logger_broker.debug ('Authenticated as username: {username}, with password: <hidden>'.format(username=username)) ### -- Alioth's /srv/git/code.x2go.org/x2gobroker.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2gobroker.git