Skip to content

Commit

Permalink
Mixed bugfixing thanks to pylint debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
evilaliv3 committed May 9, 2015
1 parent 24bbce7 commit 115193a
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 258 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Tor2web
Copyright (C) 2012 Hermes No Profit Association - GlobaLeaks Project
Copyright (C) 2011-2015 Hermes No Profit Association - GlobaLeaks Project

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
Expand Down
35 changes: 5 additions & 30 deletions tor2web/t2w.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
"""
Tor2web
Copyright (C) 2012 Hermes No Profit Association - GlobaLeaks Project
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

"""
:mod:`Tor2Web`
Expand Down Expand Up @@ -64,7 +46,6 @@
from twisted.python.compat import networkString, intToBytes
from twisted.python.failure import Failure
from twisted.python.filepath import FilePath
from twisted.python.log import err
from twisted.internet.task import LoopingCall
from tor2web import __version__
from tor2web.utils.config import Config
Expand Down Expand Up @@ -231,7 +212,7 @@ def spawnT2W(father, childFDs, fds_https, fds_http):
childFDs=childFDs)


class Tor2webObj():
class Tor2webObj(object):
def __init__(self):
# The destination hidden service identifier
self.onion = None
Expand Down Expand Up @@ -439,12 +420,6 @@ def __init__(self, channel, queued, reactor=reactor):

self.translation_rexp = {}

def finish(self):
try:
http.Request.finish()
except Exception:
pass

def getRequestHostname(self):
"""
Function overload to fix ipv6 bug:
Expand Down Expand Up @@ -496,7 +471,7 @@ def getForwarders(self):
port))
else:
raise Exception
except:
except Exception:
return []

return forwarders
Expand Down Expand Up @@ -841,7 +816,7 @@ def process(self):
ctype = ctype[0]

if self.method == b"POST" and ctype:
key, pdict = parse_header(ctype)
key, _ = parse_header(ctype)
if key == b'application/x-www-form-urlencoded':
args.update(parse_qs(content, 1))
# ################################################################
Expand Down Expand Up @@ -923,7 +898,7 @@ def process(self):

else:
if type(antanistaticmap[staticpath]) == str:
filename, ext = os.path.splitext(staticpath)
_, ext = os.path.splitext(staticpath)
self.setHeader(b'content-type', mimetypes.types_map[ext])
content = antanistaticmap[staticpath]
defer.returnValue(self.contentFinish(content))
Expand Down Expand Up @@ -1560,7 +1535,7 @@ def daemon_shutdown(self):
t2w_daemon.daemon_shutdown = daemon_shutdown
t2w_daemon.rpc_server = T2WRPCServer(config)

t2w_daemon.run(config)
t2w_daemon.run()

else:
set_proctitle("tor2web-worker")
Expand Down
20 changes: 1 addition & 19 deletions tor2web/utils/config.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
"""
Tor2web
Copyright (C) 2012 Hermes No Profit Association - GlobaLeaks Project
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

"""
:mod:`Tor2Web`
Expand Down Expand Up @@ -57,7 +39,7 @@ def __init__(self):
parser.add_option("-n", "--nodaemon", dest="nodaemon", default=False, action="store_true")
parser.add_option("-d", "--rundir", dest="rundir", default='/var/run/tor2web/')
parser.add_option("-x", "--command", dest="command", default='start')
(options, args) = parser.parse_args()
options, _ = parser.parse_args()

self._file = options.configfile

Expand Down
19 changes: 0 additions & 19 deletions tor2web/utils/daemon.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
"""
Tor2web
Copyright (C) 2012 Hermes No Profit Association - GlobaLeaks Project
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

"""
:mod:`Tor2Web`
Expand Down Expand Up @@ -193,7 +175,6 @@ def change_uid(self):
os.setuid(c_uid)

def run(self, config):

if self.config.command == 'status':
if not self.is_process_running():
exit(1)
Expand Down
22 changes: 2 additions & 20 deletions tor2web/utils/gettor.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
"""
Tor2web
Copyright (C) 2015 Hermes No Profit Association - GlobaLeaks Project
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

"""
:mod:`Tor2Web`
Expand Down Expand Up @@ -282,7 +264,7 @@ def getTorTask(config):
try:
with open (latest_tb_file, 'r') as version_file:
current_version = version_file.read().replace('\n', '')
except:
except Exception:
pass

if current_version != latest_version:
Expand Down Expand Up @@ -324,5 +306,5 @@ def getTorTask(config):
with open(latest_tb_file, 'w') as version_file:
version_file.write(latest_version)

except:
except Exception:
pass
20 changes: 1 addition & 19 deletions tor2web/utils/hostsmap.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
"""
Tor2web
Copyright (C) 2014 Hermes No Profit Association - GlobaLeaks Project
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

"""
:mod:`Tor2Web`
Expand Down Expand Up @@ -54,5 +36,5 @@ def read(self, path):
host = parts[0]
onion = parts[1]
self.hosts[host] = onion
except:
except Exception:
pass
25 changes: 3 additions & 22 deletions tor2web/utils/lists.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
"""
Tor2web
Copyright (C) 2012 Hermes No Profit Association - GlobaLeaks Project
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

"""
:mod:`Tor2Web`
Expand All @@ -37,7 +19,6 @@
from collections import OrderedDict
from StringIO import StringIO

from OpenSSL import SSL
from twisted.internet import reactor, ssl
from twisted.internet.task import LoopingCall
from twisted.internet.defer import Deferred
Expand Down Expand Up @@ -213,14 +194,14 @@ def load(self):
# simple touch to create non existent files
try:
open(self.filename, 'a').close()
except:
except Exception:
pass

try:
with open(self.filename, 'r') as fh:
for l in fh.readlines():
self.add(re.split("#", l)[0].rstrip("[ , \n,\t]"))
except:
except Exception:
pass

def dump(self):
Expand All @@ -231,7 +212,7 @@ def dump(self):
with open(self.filename, 'w') as fh:
for l in self:
fh.write(l + "\n")
except:
except Exception:
pass

def handleData(self, data):
Expand Down
18 changes: 0 additions & 18 deletions tor2web/utils/mail.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
"""
Tor2web
Copyright (C) 2012 Hermes No Profit Association - GlobaLeaks Project
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

"""
:mod:`Tor2Web`
Expand Down
18 changes: 0 additions & 18 deletions tor2web/utils/misc.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
"""
Tor2web
Copyright (C) 2012 Hermes No Profit Association - GlobaLeaks Project
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

"""
:mod:`Tor2Web`
Expand Down
18 changes: 0 additions & 18 deletions tor2web/utils/socks.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
"""
Tor2web
Copyright (C) 2012 Hermes No Profit Association - GlobaLeaks Project
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

"""
:mod:`Tor2Web`
Expand Down
21 changes: 2 additions & 19 deletions tor2web/utils/ssl.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
"""
Tor2web
Copyright (C) 2012 Hermes No Profit Association - GlobaLeaks Project
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

"""
:mod:`Tor2Web`
Expand All @@ -34,7 +16,8 @@

import os
from OpenSSL import SSL
from OpenSSL.crypto import load_certificate, dump_certificate, FILETYPE_PEM
from OpenSSL.crypto import load_certificate, dump_certificate, FILETYPE_PEM,
_raise_current_error
from pyasn1.type import univ, constraint, char, namedtype, tag
from pyasn1.codec.der.decoder import decode
from twisted.internet import ssl
Expand Down
18 changes: 0 additions & 18 deletions tor2web/utils/stats.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
"""
Tor2web
Copyright (C) 2012 Hermes No Profit Association - GlobaLeaks Project
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

"""
:mod:`Tor2Web`
Expand Down
Loading

0 comments on commit 115193a

Please sign in to comment.