Skip to content

Commit

Permalink
Remove unused imports; fix NameErrors
Browse files Browse the repository at this point in the history
Notes: twisted.runner.inetdtap.py is a mess
Notes: old cred really needs to go
Notes: lore is a mess
Notes: more notes later

git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/trunk@15092 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
exarkun committed Nov 10, 2005
1 parent 970d58b commit c527fda
Showing 44 changed files with 68 additions and 101 deletions.
11 changes: 6 additions & 5 deletions twisted/application/app.py
Original file line number Diff line number Diff line change
@@ -3,11 +3,13 @@
# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
# See LICENSE for details.

import sys, os, pdb, getpass, traceback, signal

from twisted.python import runtime, log, usage, reflect, failure, util, logfile
from twisted.persisted import sob
from twisted.application import compat, service
from twisted.application import service
from twisted.internet import defer
from twisted import copyright
import sys, os, pdb, getpass, traceback, signal

reactorTypes = {
'wx': 'twisted.internet.wxreactor',
@@ -62,7 +64,7 @@ def runWithProfiler(reactor, config):
def runWithHotshot(reactor, config):
"""Run reactor under hotshot profiler."""
try:
import hotshot, hotshot.stats
import hotshot.stats
except ImportError, e:
s = "Failed to import module hotshot: %s" % e
s += """
@@ -110,7 +112,7 @@ def set_quit(self):
pdb.Pdb.help_stop = help_stop

def runReactorWithLogging(config, oldstdout, oldstderr):
from twisted.internet import reactor, defer
from twisted.internet import reactor
try:
if config['profile']:
if sys.version_info[:2] > (2, 2) and not config['nothotshot']:
@@ -241,7 +243,6 @@ def opt_debug(self):
run the application in the Python Debugger (implies nodaemon),
sending SIGUSR2 will drop into debugger
"""
from twisted.internet import defer
defer.setDebugging(True)
failure.startDebugMode()
self['debug'] = True
6 changes: 3 additions & 3 deletions twisted/application/compat.py
Original file line number Diff line number Diff line change
@@ -14,12 +14,12 @@
Maintainer: U{Moshe Zadka<mailto:moshez@twistedmatrix.com>}
"""

from twisted.python import components
from twisted.application import internet, service
from twisted.persisted import sob
import warnings, sys

from zope.interface import implements

from twisted.python import components
from twisted.application import internet, service

class IOldApplication(components.Interface):

5 changes: 1 addition & 4 deletions twisted/application/service.py
Original file line number Diff line number Diff line change
@@ -15,14 +15,11 @@
Maintainer: U{Moshe Zadka<mailto:moshez@twistedmatrix.com>}
"""

import os
from zope.interface import implements

from twisted.python import components
from zope.interface import implements
from twisted.internet import defer
from twisted.persisted import sob
from twisted.python.runtime import platformType


class IService(components.Interface):

8 changes: 5 additions & 3 deletions twisted/cred/checkers.py
Original file line number Diff line number Diff line change
@@ -4,11 +4,13 @@

from __future__ import generators

import os

from zope import interface
from twisted.internet import reactor, threads, defer

from twisted.internet import defer
from twisted.python import components, failure, log
from twisted.cred import error, credentials
import os

try:
from twisted.cred import pamauth
@@ -249,7 +251,7 @@ class PluggableAuthenticationModulesChecker:

def requestAvatarId(self, credentials):
if not pamauth:
return defer.fail(UnauthorizedLogin())
return defer.fail(error.UnauthorizedLogin())
d = pamauth.pamAuthenticate(self.service, credentials.username,
credentials.pamConversion)
d.addCallback(lambda x: credentials.username)
7 changes: 4 additions & 3 deletions twisted/cred/pamauth.py
Original file line number Diff line number Diff line change
@@ -9,11 +9,12 @@
from __future__ import nested_scopes

import PAM

import getpass, threading, os

from twisted.internet import reactor
from twisted.internet import threads, defer

import sys, time, getpass, threading, os

def pamAuthenticateThread(service, user, conv):
def _conv(items):
try:
@@ -45,7 +46,7 @@ def callIntoPAM(service, user, conv):
pam = PAM.pam()
pam.start(service)
pam.set_item(PAM.PAM_USER, user)
pam.set_item(PAM.PAM_CONV, _conv)
pam.set_item(PAM.PAM_CONV, conv)
gid = os.getegid()
uid = os.geteuid()
os.setegid(0)
4 changes: 2 additions & 2 deletions twisted/enterprise/sqlreflector.py
Original file line number Diff line number Diff line change
@@ -3,9 +3,9 @@
# See LICENSE for details.


from twisted.enterprise import adbapi, reflector
from twisted.enterprise import reflector
from twisted.enterprise.util import DBError, getKeyColumn, quote, safe
from twisted.enterprise.util import _TableInfo, _TableRelationship
from twisted.enterprise.util import _TableInfo
from twisted.enterprise.row import RowObject

from twisted.python import reflect
2 changes: 0 additions & 2 deletions twisted/names/authority.py
Original file line number Diff line number Diff line change
@@ -6,8 +6,6 @@
from __future__ import nested_scopes

import os
import copy
import operator
import time

from twisted.names import dns
3 changes: 2 additions & 1 deletion twisted/names/cache.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,8 @@
# See LICENSE for details.


import operator, time, copy
import time

from zope.interface import implements

from twisted.names import dns
5 changes: 1 addition & 4 deletions twisted/names/client.py
Original file line number Diff line number Diff line change
@@ -16,15 +16,12 @@

from __future__ import nested_scopes

import warnings
import socket
import os
import errno
import time

# Twisted imports
from twisted.python.runtime import platform
from twisted.internet import error, defer, protocol, interfaces, threads
from twisted.internet import error, defer, protocol, interfaces
from twisted.python import log, failure, components
from twisted.names import dns
from zope.interface import implements
4 changes: 2 additions & 2 deletions twisted/names/common.py
Original file line number Diff line number Diff line change
@@ -3,11 +3,11 @@
# See LICENSE for details.


import operator, sys, socket, random
import socket

from twisted.names import dns
from twisted.internet import defer, error
from twisted.python import failure, log
from twisted.python import failure

EMPTY_RESULT = (), (), ()

4 changes: 2 additions & 2 deletions twisted/names/dns.py
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
import warnings

import struct, random, types, socket
from math import ceil, floor

try:
import cStringIO as StringIO
except ImportError:
@@ -60,7 +60,7 @@ def randomSource(r = randpool.RandomPool().get_bytes):


# Twisted imports
from twisted.internet import protocol, defer, error
from twisted.internet import protocol, defer
from twisted.python import log, failure
from twisted.python import util as tputil
from twisted.python import components
2 changes: 1 addition & 1 deletion twisted/names/hosts.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
from twisted.names import dns
from twisted.persisted import styles
from twisted.python import failure
from twisted.internet import interfaces, defer
from twisted.internet import defer

from twisted.names import common

5 changes: 1 addition & 4 deletions twisted/names/root.py
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@

from __future__ import generators

import random
import sys

from twisted.python import log
from twisted.internet import defer
@@ -189,7 +189,6 @@ def bootstrap(resolver):
to look up.
"""
domains = [chr(ord('a') + i) for i in range(13)]
from twisted.python import log
# f = lambda r: (log.msg('Root server address: ' + str(r)), r)[1]
f = lambda r: r
L = [resolver.getHostByName('%s.root-servers.net' % d).addCallback(f) for d in domains]
@@ -198,8 +197,6 @@ def bootstrap(resolver):
return DeferredResolver(d)

if __name__ == '__main__':
from twisted.python import log
import sys
if len(sys.argv) < 2:
print 'Specify a domain'
else:
1 change: 0 additions & 1 deletion twisted/names/secondary.py
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
from twisted.names import dns
from twisted.names import common
from twisted.names import client
from twisted.names import server
from twisted.names import resolve
from twisted.python import log, failure
from twisted.application import service
7 changes: 3 additions & 4 deletions twisted/names/server.py
Original file line number Diff line number Diff line change
@@ -21,15 +21,14 @@
"""

from __future__ import nested_scopes
import copy
import time

# Twisted imports
from twisted.internet import protocol, defer
from twisted.internet import protocol
from twisted.names import dns
from twisted.python import failure, log
from twisted.python import log

import resolve, common
import resolve

class DNSServerFactory(protocol.ServerFactory):
protocol = dns.DNSProtocol
2 changes: 0 additions & 2 deletions twisted/names/test/test_dns.py
Original file line number Diff line number Diff line change
@@ -6,8 +6,6 @@
Tests for twisted.names.dns.
"""

import socket

try:
from cStringIO import StringIO
except ImportError:
7 changes: 4 additions & 3 deletions twisted/names/test/test_names.py
Original file line number Diff line number Diff line change
@@ -7,13 +7,14 @@
"""
from __future__ import nested_scopes

import sys, socket, operator, copy
import socket, operator, copy

from twisted.trial import unittest
from twisted.trial.util import wait, spinUntil

from twisted.internet import reactor, protocol, defer, error
from twisted.internet import reactor, defer, error
from twisted.names import client, server, common, authority, hosts, dns
from twisted.python import log, failure
from twisted.python import failure

def justPayload(results):
return [r.payload for r in results[0]]
2 changes: 0 additions & 2 deletions twisted/names/test/test_rootresolve.py
Original file line number Diff line number Diff line change
@@ -7,8 +7,6 @@
Test cases for Twisted.names' root resolver.
"""

from twisted.internet import defer
from twisted.names import root, dns
from twisted.trial import unittest

class RootResolverTestCase(unittest.TestCase):
4 changes: 2 additions & 2 deletions twisted/news/database.py
Original file line number Diff line number Diff line change
@@ -260,7 +260,7 @@ def getModerators(self, groups):
def notifyModerators(self, moderators, article):
# Moderated postings go through as long as they have an Approved
# header, regardless of what the value is
a.putHeader('To', ', '.join(moderators))
article.putHeader('To', ', '.join(moderators))
return smtp.sendEmail(
'twisted@' + socket.gethostname(),
moderators,
@@ -316,7 +316,7 @@ def postRequest(self, message):

a.putHeader('Xref', '%s %s' % (
socket.gethostname().split()[0],
''.join(map(lambda x: string.join(x, ':'), xref))
''.join(map(lambda x: ':'.join(x), xref))
))

self.flush()
8 changes: 3 additions & 5 deletions twisted/news/nntp.py
Original file line number Diff line number Diff line change
@@ -32,11 +32,6 @@
- A control protocol
"""

from twisted.internet import protocol
from twisted.protocols import basic
from twisted.python import log
from twisted.python import failure

import time
import types

@@ -45,6 +40,9 @@
except:
import StringIO

from twisted.protocols import basic
from twisted.python import log

def parseRange(text):
articles = text.split('-')
if len(articles) == 1:
3 changes: 0 additions & 3 deletions twisted/news/tap.py
Original file line number Diff line number Diff line change
@@ -2,13 +2,10 @@
# See LICENSE for details.


from twisted.enterprise import adbapi
from twisted.news import news, database
from twisted.application import strports
from twisted.python import usage, log

import sys, getpass

class DBOptions(usage.Options):
optParameters = [
['module', None, 'pyPgSQL.PgSQL', "DB-API 2.0 module to use"],
4 changes: 2 additions & 2 deletions twisted/news/test/test_news.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
# See LICENSE for details.

import os, types
import sys, types
from pprint import pformat

from twisted.trial import unittest
from twisted.news import news, database
from twisted.news import database
from twisted.internet import reactor

MESSAGE_ID = "f83ba57450ed0fd8ac9a472b847e830e"
5 changes: 1 addition & 4 deletions twisted/news/test/test_nntp.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
# See LICENSE for details.

import os, string, shutil

from twisted.trial import unittest
from twisted.news import news, database
from twisted.news import database
from twisted.news import nntp
from twisted.protocols import loopback
from twisted.internet import reactor, protocol

ALL_GROUPS = ('alt.test.nntp', 0, 1, 'y'),
GROUP = ('0', '1', '0', 'alt.test.nntp', 'group', 'selected')
1 change: 0 additions & 1 deletion twisted/news/topfiles/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys

try:
from twisted.python import dist
Loading
Oops, something went wrong.

0 comments on commit c527fda

Please sign in to comment.