[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [arm/master] Correcting issues caught by pyflakes
commit 2ca15491a70a3c175d70dea24b2d4c7fdfd3b1a3
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Tue Dec 31 09:49:17 2013 -0800
Correcting issues caught by pyflakes
So many bugs. Also some unused imports, and our first couple false positives to
ignore.
---
arm/connections/connPanel.py | 2 +-
arm/controller.py | 5 ++---
arm/headerPanel.py | 11 ++++-------
arm/torrcPanel.py | 2 +-
arm/util/__init__.py | 2 --
arm/util/torTools.py | 9 ++++-----
arm/util/tracker.py | 4 ++--
run_tests.py | 3 +++
8 files changed, 17 insertions(+), 21 deletions(-)
diff --git a/arm/connections/connPanel.py b/arm/connections/connPanel.py
index 4abc068..cbf9902 100644
--- a/arm/connections/connPanel.py
+++ b/arm/connections/connPanel.py
@@ -60,7 +60,7 @@ class ConnectionPanel(panel.Panel, threading.Thread):
if not CONFIG["features.connection.showIps"] and CONFIG["features.connection.listingType"] == 0:
armConf = conf.get_config("arm")
- armConf.set("features.connection.listingType", enumeration.keys()[Listing.index_of(Listing.FINGERPRINT)])
+ armConf.set("features.connection.listingType", Listing.keys()[Listing.index_of(Listing.FINGERPRINT)])
self._scroller = uiTools.Scroller(True)
self._title = "Connections:" # title line of the panel
diff --git a/arm/controller.py b/arm/controller.py
index 9784ab4..d907b40 100644
--- a/arm/controller.py
+++ b/arm/controller.py
@@ -6,7 +6,6 @@ user input to the proper panels.
import os
import time
import curses
-import sys
import threading
import arm.arguments
@@ -23,9 +22,9 @@ import arm.graphing.resourceStats
import arm.connections.connPanel
import arm.util.tracker
-from stem.control import State, Controller
+from stem.control import State
-from arm.util import connections, panel, torConfig, torTools
+from arm.util import panel, torConfig, torTools
from stem.util import conf, enum, log, system
diff --git a/arm/headerPanel.py b/arm/headerPanel.py
index 3420ade..addde9d 100644
--- a/arm/headerPanel.py
+++ b/arm/headerPanel.py
@@ -22,10 +22,9 @@ import threading
import arm.util.tracker
import stem
-import stem.connection
-from stem.control import State, Controller
-from stem.util import conf, str_tools
+from stem.control import State
+from stem.util import conf, log, str_tools
import arm.starter
import arm.popups
@@ -33,8 +32,6 @@ import arm.controller
from util import panel, sysTools, torTools, uiTools
-from stem.util import log, str_tools
-
# minimum width for which panel attempts to double up contents (two columns to
# better use screen real estate)
MIN_DUAL_COL_WIDTH = 141
@@ -136,8 +133,8 @@ class HeaderPanel(panel.Panel, threading.Thread):
if key in (ord('n'), ord('N')) and torTools.getConn().isNewnymAvailable():
self.sendNewnym()
elif key in (ord('r'), ord('R')) and not self._isTorConnected:
- oldSocket = torTools.getConn().getController().get_socket()
-
+ #oldSocket = torTools.getConn().getController().get_socket()
+ #
#controller = None
#allowPortConnection, allowSocketConnection, _ = starter.allowConnectionTypes()
#
diff --git a/arm/torrcPanel.py b/arm/torrcPanel.py
index d6d8123..4940302 100644
--- a/arm/torrcPanel.py
+++ b/arm/torrcPanel.py
@@ -109,7 +109,7 @@ class TorrcPanel(panel.Panel):
self._lastContentHeightArgs = None
self.redraw(True)
- popups.showMsg(resultMsg, 1)
+ arm.popups.showMsg(resultMsg, 1)
def handleKey(self, key):
self.valsLock.acquire()
diff --git a/arm/util/__init__.py b/arm/util/__init__.py
index bd43761..e597b26 100644
--- a/arm/util/__init__.py
+++ b/arm/util/__init__.py
@@ -9,8 +9,6 @@ __all__ = ["connections", "panel", "sysTools", "textInput", "torConfig", "torToo
import getpass
import os
-import arm.util.torTools
-
import stem
import stem.connection
import stem.control
diff --git a/arm/util/torTools.py b/arm/util/torTools.py
index 69cd574..3749972 100644
--- a/arm/util/torTools.py
+++ b/arm/util/torTools.py
@@ -319,7 +319,7 @@ class Controller:
hs_port = entry # just has the virtual port
if hs_port.isdigit():
- result.append(hsPort)
+ result.append(hs_port)
if result:
return result
@@ -391,7 +391,7 @@ class Controller:
myDescriptor = self.controller.get_server_descriptor(myFingerprint)
if myDescriptor:
- result = myDescriptor.observed_bandwidth
+ return myDescriptor.observed_bandwidth
return default
@@ -450,7 +450,7 @@ class Controller:
try:
return self.controller.get_version()
- except stem.SocketClosed, exc:
+ except stem.SocketClosed:
self.close()
return None
except:
@@ -587,7 +587,7 @@ class Controller:
result = None
if self.isAlive():
try:
- result = self.controller.get_exit_policy(param)
+ result = self.controller.get_exit_policy(None)
except:
pass
@@ -878,7 +878,6 @@ class Controller:
def new_desc_event(self, event):
self.connLock.acquire()
- myFingerprint = self.getInfo("fingerprint", None)
desc_fingerprints = [fingerprint for (fingerprint, nickname) in event.relays]
# If we're tracking ip address -> fingerprint mappings then update with
diff --git a/arm/util/tracker.py b/arm/util/tracker.py
index f9e60f8..6148361 100644
--- a/arm/util/tracker.py
+++ b/arm/util/tracker.py
@@ -177,11 +177,11 @@ def _resources_via_proc(pid):
)
total_cpu_time = float(utime) + float(stime)
- memory_in_bytes = proc.get_memory_usage(process_pid)[0]
+ memory_in_bytes = proc.get_memory_usage(pid)[0]
total_memory = proc.get_physical_memory()
uptime = time.time() - float(start_time)
- memory_in_percent = float(mem_usage) / total_memory
+ memory_in_percent = float(memory_in_bytes) / total_memory
return (total_cpu_time, uptime, memory_in_bytes, memory_in_percent)
diff --git a/run_tests.py b/run_tests.py
index fb326f8..0135708 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -100,6 +100,9 @@ def get_pyflakes_issues(paths):
def main():
load_settings()
+ test_config = stem.util.conf.get_config("test")
+ test_config.load(os.path.join(ARM_BASE, "test", "settings.cfg"))
+
clean_orphaned_pyc()
tests = unittest.defaultTestLoader.discover('test', pattern='*.py')
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits