Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
irl committed Oct 18, 2016
1 parent d22e9dd commit 4851a6f
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 45 deletions.
12 changes: 6 additions & 6 deletions pathspider/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def __init__(self, worker_count, libtrace_uri, args):
self.restab = {}
self.flowtab = {}
self.flowreap = collections.deque()
self.flowreap_size = min(self.worker_count * 100, 10000)
self.flowreap_size = min(self.worker_count * 100, 10000)

self.outqueue = queue.Queue(QUEUE_SIZE)

Expand Down Expand Up @@ -708,7 +708,7 @@ def configurator(self):

def worker(self, worker_number):
"""
This function provides the logic for
This function provides the logic for
configuration-synchronized worker threads.
:param worker_number: The unique number of the worker.
Expand All @@ -729,7 +729,7 @@ def worker(self, worker_number):
* Perform post-connection operations for config_one and pass the
result to the merger
* Do it all again
If the job fetched is the SHUTDOWN_SENTINEL, then the worker will
terminate as this indicates that all the jobs have now been processed.
"""
Expand Down Expand Up @@ -826,15 +826,15 @@ def config_one(self):

def configurator(self):
"""
Since there is no need for a configurator thread in a
Since there is no need for a configurator thread in a
desynchronized spider, this thread is a no-op
"""
logger = logging.getLogger('pathspider')
logger.info("configurations are not synchronized")

def worker(self, worker_number):
"""
This function provides the logic for
This function provides the logic for
configuration-synchronized worker threads.
:param worker_number: The unique number of the worker.
Expand All @@ -855,7 +855,7 @@ def worker(self, worker_number):
* Perform post-connection operations for config_one and pass the
result to the merger
* Do it all again
If the job fetched is the SHUTDOWN_SENTINEL, then the worker will
terminate as this indicates that all the jobs have now been processed.
"""
Expand Down
6 changes: 3 additions & 3 deletions pathspider/observer/tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def tcp_handshake(rec, tcp, rev):

return True

def tcp_complete(rec, tcp, rev): # pylint: disable=W0612,W0613
def tcp_complete(rec, tcp, rev):
if tcp.fin_flag and rev:
rec['rev_fin'] = True
if tcp.fin_flag and not rev:
Expand All @@ -50,6 +50,6 @@ def tcp_complete(rec, tcp, rev): # pylint: disable=W0612,W0613
if tcp.rst_flag and not rev:
rec['fwd_rst'] = True

return not ( ( rec['fwd_fin'] and rec['rev_fin'] ) or
rec['fwd_rst'] or rec['rev_rst'] )
return not ((rec['fwd_fin'] and rec['rev_fin']) or
rec['fwd_rst'] or rec['rev_rst'])

41 changes: 18 additions & 23 deletions pathspider/plugins/ecn.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,12 @@ def ecn_code(rec, ip, rev):
EO = 0x01
CE = 0x03

if (ip.traffic_class & CE == EZ):
if rev:
rec['rev_ez'] = True
else:
rec['fwd_ez'] = True
if (ip.traffic_class & CE == EO):
if rev:
rec['rev_eo'] = True
else:
rec['fwd_eo'] = True
if (ip.traffic_class & CE == CE):
if rev:
rec['rev_ce'] = True
else:
rec['fwd_ce'] = True
if ip.traffic_class & CE == EZ:
rec['rev_ez' if rev else 'fwd_ez'] = True
if ip.traffic_class & CE == EO:
rec['rev_eo' if rev else 'fwd_eo'] = True
if ip.traffic_class & CE == CE:
rec['rev_ce' if rev else 'fwd_ce'] = True

return True

Expand Down Expand Up @@ -106,18 +97,20 @@ def post_connect(self, job, conn, pcs, config):
tstop = str(datetime.utcnow())

if conn.state == Conn.OK:
rec = SpiderRecord(job_ip, job_port, conn.port, job_rank, job_host, config, True, conn.tstart, tstop)
rec = SpiderRecord(job_ip, job_port, conn.port, job_rank, job_host,
config, True, conn.tstart, tstop)
else:
rec = SpiderRecord(job_ip, job_port, conn.port, job_rank, job_host, config, False, conn.tstart, tstop)
rec = SpiderRecord(job_ip, job_port, conn.port, job_rank, job_host,
config, False, conn.tstart, tstop)

try:
conn.client.shutdown(socket.SHUT_RDWR)
except:
except: # FIXME: What are we catching?
pass

try:
conn.client.close()
except:
except: # FIXME: What are we catching?
pass

return rec
Expand Down Expand Up @@ -207,10 +200,12 @@ def merge(self, flow, res):

logger = logging.getLogger('ecn')
if flow == NO_FLOW:
flow = {"dip": res.ip,
"sp": res.port,
"dp": res.rport,
"observed": False }
flow = {
"dip": res.ip,
"sp": res.port,
"dp": res.rport,
"observed": False,
}
else:
flow['observed'] = True

Expand Down
9 changes: 8 additions & 1 deletion pathspider/plugins/tfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,14 @@ def create_observer(self):
def merge(self, flow, res):
logger = logging.getLogger('tfo')
if flow == NO_FLOW:
flow = {"dip": res.ip, "sp": res.port, "dp": res.rport, "connstate": res.connstate, "config": res.config, "observed": False }
flow = {
"dip": res.ip,
"sp": res.port,
"dp": res.rport,
"connstate": res.connstate,
"config": res.config,
"observed": False,
}
else:
flow['connstate'] = res.connstate
flow['host'] = res.host
Expand Down
10 changes: 1 addition & 9 deletions pathspider/run.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@

import argparse
import csv
import sys
import logging
import time
import threading
import json


from straight.plugin import load

from pathspider.base import PluggableSpider
from pathspider.base import SHUTDOWN_SENTINEL

import pathspider.util.dnsresolv

import sys

plugins = load("pathspider.plugins", subclasses=PluggableSpider)

Expand Down Expand Up @@ -66,8 +60,6 @@ def _format_action(self, action):
else:
logging.getLogger().setLevel(logging.INFO)

logger = logging.getLogger("pathspider")

if hasattr(args, "func"):
# Run a utility function
sys.exit(args.func(args))
Expand Down
3 changes: 0 additions & 3 deletions pathspider/standalone.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
import sys
import threading

from straight.plugin import load

from pathspider.base import PluggableSpider
from pathspider.base import SHUTDOWN_SENTINEL


Expand Down

0 comments on commit 4851a6f

Please sign in to comment.