Skip to content

Commit 115193a

Browse files
committed
Mixed bugfixing thanks to pylint debugger
1 parent 24bbce7 commit 115193a

File tree

14 files changed

+16
-258
lines changed

14 files changed

+16
-258
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Tor2web
2-
Copyright (C) 2012 Hermes No Profit Association - GlobaLeaks Project
2+
Copyright (C) 2011-2015 Hermes No Profit Association - GlobaLeaks Project
33

44
This program is free software: you can redistribute it and/or modify
55
it under the terms of the GNU Affero General Public License as published by

tor2web/t2w.py

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
1-
"""
2-
Tor2web
3-
Copyright (C) 2012 Hermes No Profit Association - GlobaLeaks Project
4-
5-
This program is free software: you can redistribute it and/or modify
6-
it under the terms of the GNU Affero General Public License as published by
7-
the Free Software Foundation, either version 3 of the License, or
8-
(at your option) any later version.
9-
10-
This program is distributed in the hope that it will be useful,
11-
but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-
GNU Affero General Public License for more details.
14-
15-
You should have received a copy of the GNU Affero General Public License
16-
along with this program. If not, see <http://www.gnu.org/licenses/>.
17-
"""
18-
191
"""
202
213
:mod:`Tor2Web`
@@ -64,7 +46,6 @@
6446
from twisted.python.compat import networkString, intToBytes
6547
from twisted.python.failure import Failure
6648
from twisted.python.filepath import FilePath
67-
from twisted.python.log import err
6849
from twisted.internet.task import LoopingCall
6950
from tor2web import __version__
7051
from tor2web.utils.config import Config
@@ -231,7 +212,7 @@ def spawnT2W(father, childFDs, fds_https, fds_http):
231212
childFDs=childFDs)
232213

233214

234-
class Tor2webObj():
215+
class Tor2webObj(object):
235216
def __init__(self):
236217
# The destination hidden service identifier
237218
self.onion = None
@@ -439,12 +420,6 @@ def __init__(self, channel, queued, reactor=reactor):
439420

440421
self.translation_rexp = {}
441422

442-
def finish(self):
443-
try:
444-
http.Request.finish()
445-
except Exception:
446-
pass
447-
448423
def getRequestHostname(self):
449424
"""
450425
Function overload to fix ipv6 bug:
@@ -496,7 +471,7 @@ def getForwarders(self):
496471
port))
497472
else:
498473
raise Exception
499-
except:
474+
except Exception:
500475
return []
501476

502477
return forwarders
@@ -841,7 +816,7 @@ def process(self):
841816
ctype = ctype[0]
842817

843818
if self.method == b"POST" and ctype:
844-
key, pdict = parse_header(ctype)
819+
key, _ = parse_header(ctype)
845820
if key == b'application/x-www-form-urlencoded':
846821
args.update(parse_qs(content, 1))
847822
# ################################################################
@@ -923,7 +898,7 @@ def process(self):
923898

924899
else:
925900
if type(antanistaticmap[staticpath]) == str:
926-
filename, ext = os.path.splitext(staticpath)
901+
_, ext = os.path.splitext(staticpath)
927902
self.setHeader(b'content-type', mimetypes.types_map[ext])
928903
content = antanistaticmap[staticpath]
929904
defer.returnValue(self.contentFinish(content))
@@ -1560,7 +1535,7 @@ def daemon_shutdown(self):
15601535
t2w_daemon.daemon_shutdown = daemon_shutdown
15611536
t2w_daemon.rpc_server = T2WRPCServer(config)
15621537

1563-
t2w_daemon.run(config)
1538+
t2w_daemon.run()
15641539

15651540
else:
15661541
set_proctitle("tor2web-worker")

tor2web/utils/config.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
1-
"""
2-
Tor2web
3-
Copyright (C) 2012 Hermes No Profit Association - GlobaLeaks Project
4-
5-
This program is free software: you can redistribute it and/or modify
6-
it under the terms of the GNU Affero General Public License as published by
7-
the Free Software Foundation, either version 3 of the License, or
8-
(at your option) any later version.
9-
10-
This program is distributed in the hope that it will be useful,
11-
but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-
GNU Affero General Public License for more details.
14-
15-
You should have received a copy of the GNU Affero General Public License
16-
along with this program. If not, see <http://www.gnu.org/licenses/>.
17-
"""
18-
191
"""
202
213
:mod:`Tor2Web`
@@ -57,7 +39,7 @@ def __init__(self):
5739
parser.add_option("-n", "--nodaemon", dest="nodaemon", default=False, action="store_true")
5840
parser.add_option("-d", "--rundir", dest="rundir", default='/var/run/tor2web/')
5941
parser.add_option("-x", "--command", dest="command", default='start')
60-
(options, args) = parser.parse_args()
42+
options, _ = parser.parse_args()
6143

6244
self._file = options.configfile
6345

tor2web/utils/daemon.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
1-
"""
2-
Tor2web
3-
Copyright (C) 2012 Hermes No Profit Association - GlobaLeaks Project
4-
5-
This program is free software: you can redistribute it and/or modify
6-
it under the terms of the GNU Affero General Public License as published by
7-
the Free Software Foundation, either version 3 of the License, or
8-
(at your option) any later version.
9-
10-
This program is distributed in the hope that it will be useful,
11-
but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-
GNU Affero General Public License for more details.
14-
15-
You should have received a copy of the GNU Affero General Public License
16-
along with this program. If not, see <http://www.gnu.org/licenses/>.
17-
"""
18-
191
"""
202
213
:mod:`Tor2Web`
@@ -193,7 +175,6 @@ def change_uid(self):
193175
os.setuid(c_uid)
194176

195177
def run(self, config):
196-
197178
if self.config.command == 'status':
198179
if not self.is_process_running():
199180
exit(1)

tor2web/utils/gettor.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
1-
"""
2-
Tor2web
3-
Copyright (C) 2015 Hermes No Profit Association - GlobaLeaks Project
4-
5-
This program is free software: you can redistribute it and/or modify
6-
it under the terms of the GNU Affero General Public License as published by
7-
the Free Software Foundation, either version 3 of the License, or
8-
(at your option) any later version.
9-
10-
This program is distributed in the hope that it will be useful,
11-
but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-
GNU Affero General Public License for more details.
14-
15-
You should have received a copy of the GNU Affero General Public License
16-
along with this program. If not, see <http://www.gnu.org/licenses/>.
17-
"""
18-
191
"""
202
213
:mod:`Tor2Web`
@@ -282,7 +264,7 @@ def getTorTask(config):
282264
try:
283265
with open (latest_tb_file, 'r') as version_file:
284266
current_version = version_file.read().replace('\n', '')
285-
except:
267+
except Exception:
286268
pass
287269

288270
if current_version != latest_version:
@@ -324,5 +306,5 @@ def getTorTask(config):
324306
with open(latest_tb_file, 'w') as version_file:
325307
version_file.write(latest_version)
326308

327-
except:
309+
except Exception:
328310
pass

tor2web/utils/hostsmap.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
1-
"""
2-
Tor2web
3-
Copyright (C) 2014 Hermes No Profit Association - GlobaLeaks Project
4-
5-
This program is free software: you can redistribute it and/or modify
6-
it under the terms of the GNU Affero General Public License as published by
7-
the Free Software Foundation, either version 3 of the License, or
8-
(at your option) any later version.
9-
10-
This program is distributed in the hope that it will be useful,
11-
but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-
GNU Affero General Public License for more details.
14-
15-
You should have received a copy of the GNU Affero General Public License
16-
along with this program. If not, see <http://www.gnu.org/licenses/>.
17-
"""
18-
191
"""
202
213
:mod:`Tor2Web`
@@ -54,5 +36,5 @@ def read(self, path):
5436
host = parts[0]
5537
onion = parts[1]
5638
self.hosts[host] = onion
57-
except:
39+
except Exception:
5840
pass

tor2web/utils/lists.py

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
1-
"""
2-
Tor2web
3-
Copyright (C) 2012 Hermes No Profit Association - GlobaLeaks Project
4-
5-
This program is free software: you can redistribute it and/or modify
6-
it under the terms of the GNU Affero General Public License as published by
7-
the Free Software Foundation, either version 3 of the License, or
8-
(at your option) any later version.
9-
10-
This program is distributed in the hope that it will be useful,
11-
but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-
GNU Affero General Public License for more details.
14-
15-
You should have received a copy of the GNU Affero General Public License
16-
along with this program. If not, see <http://www.gnu.org/licenses/>.
17-
"""
18-
191
"""
202
213
:mod:`Tor2Web`
@@ -37,7 +19,6 @@
3719
from collections import OrderedDict
3820
from StringIO import StringIO
3921

40-
from OpenSSL import SSL
4122
from twisted.internet import reactor, ssl
4223
from twisted.internet.task import LoopingCall
4324
from twisted.internet.defer import Deferred
@@ -213,14 +194,14 @@ def load(self):
213194
# simple touch to create non existent files
214195
try:
215196
open(self.filename, 'a').close()
216-
except:
197+
except Exception:
217198
pass
218199

219200
try:
220201
with open(self.filename, 'r') as fh:
221202
for l in fh.readlines():
222203
self.add(re.split("#", l)[0].rstrip("[ , \n,\t]"))
223-
except:
204+
except Exception:
224205
pass
225206

226207
def dump(self):
@@ -231,7 +212,7 @@ def dump(self):
231212
with open(self.filename, 'w') as fh:
232213
for l in self:
233214
fh.write(l + "\n")
234-
except:
215+
except Exception:
235216
pass
236217

237218
def handleData(self, data):

tor2web/utils/mail.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
1-
"""
2-
Tor2web
3-
Copyright (C) 2012 Hermes No Profit Association - GlobaLeaks Project
4-
5-
This program is free software: you can redistribute it and/or modify
6-
it under the terms of the GNU Affero General Public License as published by
7-
the Free Software Foundation, either version 3 of the License, or
8-
(at your option) any later version.
9-
10-
This program is distributed in the hope that it will be useful,
11-
but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-
GNU Affero General Public License for more details.
14-
15-
You should have received a copy of the GNU Affero General Public License
16-
along with this program. If not, see <http://www.gnu.org/licenses/>.
17-
"""
18-
191
"""
202
213
:mod:`Tor2Web`

tor2web/utils/misc.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
1-
"""
2-
Tor2web
3-
Copyright (C) 2012 Hermes No Profit Association - GlobaLeaks Project
4-
5-
This program is free software: you can redistribute it and/or modify
6-
it under the terms of the GNU Affero General Public License as published by
7-
the Free Software Foundation, either version 3 of the License, or
8-
(at your option) any later version.
9-
10-
This program is distributed in the hope that it will be useful,
11-
but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-
GNU Affero General Public License for more details.
14-
15-
You should have received a copy of the GNU Affero General Public License
16-
along with this program. If not, see <http://www.gnu.org/licenses/>.
17-
"""
18-
191
"""
202
213
:mod:`Tor2Web`

tor2web/utils/socks.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
1-
"""
2-
Tor2web
3-
Copyright (C) 2012 Hermes No Profit Association - GlobaLeaks Project
4-
5-
This program is free software: you can redistribute it and/or modify
6-
it under the terms of the GNU Affero General Public License as published by
7-
the Free Software Foundation, either version 3 of the License, or
8-
(at your option) any later version.
9-
10-
This program is distributed in the hope that it will be useful,
11-
but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-
GNU Affero General Public License for more details.
14-
15-
You should have received a copy of the GNU Affero General Public License
16-
along with this program. If not, see <http://www.gnu.org/licenses/>.
17-
"""
18-
191
"""
202
213
:mod:`Tor2Web`

0 commit comments

Comments
 (0)