pyflakes cleanups, unused modules, and variables

This commit is contained in:
kapil.foss@gmail.com 2010-07-30 08:20:07 -04:00
parent 138cf266e7
commit 65358e873f
19 changed files with 28 additions and 60 deletions

View File

@ -17,7 +17,6 @@ import os
import socket
import time
from random import choice, random
from urllib import quote
from eventlet import Timeout
@ -72,7 +71,6 @@ class AccountAuditor(object):
time.sleep(random() * self.interval)
while True:
begin = time.time()
pids = []
for device in os.listdir(self.devices):
if self.mount_check and not \
os.path.ismount(os.path.join(self.devices, device)):

View File

@ -14,24 +14,22 @@
# limitations under the License.
from __future__ import with_statement
import errno
import os
import time
import traceback
from datetime import datetime
from urllib import unquote
from swift.common.utils import get_logger
import sqlite3
from webob import Request, Response
from webob.exc import HTTPAccepted, HTTPBadRequest, HTTPConflict, \
from webob.exc import HTTPAccepted, HTTPBadRequest, \
HTTPCreated, HTTPForbidden, HTTPInternalServerError, \
HTTPMethodNotAllowed, HTTPNoContent, HTTPNotFound, HTTPPreconditionFailed
import simplejson
from xml.sax import saxutils
from swift.common.db import AccountBroker
from swift.common.exceptions import MessageTimeout
from swift.common.utils import get_param, split_path, storage_directory, \
hash_path
from swift.common.constraints import ACCOUNT_LISTING_LIMIT, \

View File

@ -27,7 +27,7 @@ from webob.exc import HTTPBadRequest, HTTPNoContent, HTTPUnauthorized, \
HTTPServiceUnavailable, HTTPNotFound
from swift.common.bufferedhttp import http_connect
from swift.common.db import DatabaseConnectionError, get_db_connection
from swift.common.db import get_db_connection
from swift.common.ring import Ring
from swift.common.utils import get_logger, normalize_timestamp, split_path

View File

@ -13,8 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from ConfigParser import ConfigParser, NoOptionError
import os
import time
from webob.request import Request

View File

@ -38,8 +38,6 @@ CONTAINER_LISTING_LIMIT = 10000
ACCOUNT_LISTING_LIMIT = 10000
def check_metadata(req):
"""
Check metadata sent for objects in the request headers.

View File

@ -27,7 +27,6 @@ import cPickle as pickle
import errno
from random import randint
from tempfile import mkstemp
import math
from eventlet import sleep
import sqlite3
@ -332,7 +331,7 @@ class DatabaseBroker(object):
:param delete_timestamp: delete timestamp
"""
with self.get() as conn:
row = conn.execute('''
conn.execute('''
UPDATE %s_stat SET created_at=MIN(?, created_at),
put_timestamp=MAX(?, put_timestamp),
delete_timestamp=MAX(?, delete_timestamp)
@ -919,7 +918,7 @@ class ContainerBroker(DatabaseBroker):
with self.get() as conn:
max_rowid = -1
for rec in item_list:
curs = conn.execute('''
conn.execute('''
DELETE FROM object WHERE name = ? AND
(created_at < ?)
''', (rec['name'], rec['created_at']))

View File

@ -14,7 +14,6 @@
# limitations under the License.
from array import array
from bisect import bisect
from random import randint
from time import time

View File

@ -15,7 +15,6 @@
import cPickle as pickle
from gzip import GzipFile
from hashlib import md5
from os.path import getmtime
from struct import unpack_from
from time import time

View File

@ -67,6 +67,7 @@ def load_libc_function(func_name):
except AttributeError:
logging.warn("Unable to locate %s in libc. Leaving as a no-op."
% func_name)
def noop_libc_function(*args):
return 0
return noop_libc_function

View File

@ -58,7 +58,6 @@ def monkey_patch_mimetools():
# We might be able to pull pieces of this out to test, but right now it seems
# like more work than it's worth.
def run_wsgi(app, conf, *args, **kwargs): # pragma: no cover
"""
Loads common settings from conf, then instantiates app and runs

View File

@ -87,7 +87,6 @@ class ContainerAuditor(object):
time.sleep(random() * self.interval)
while True:
begin = time.time()
pids = []
for device in os.listdir(self.devices):
if self.mount_check and not\
os.path.ismount(os.path.join(self.devices, device)):
@ -184,7 +183,6 @@ class ContainerAuditor(object):
resp = conn.getresponse()
body = resp.read()
if 200 <= resp.status <= 299:
good_reponse = True
for cname in body.split('\n'):
if cname == info['container']:
found = True

View File

@ -14,9 +14,8 @@
# limitations under the License.
from __future__ import with_statement
import errno
import os
import socket
import time
import traceback
from urllib import unquote
@ -25,20 +24,19 @@ from datetime import datetime
import simplejson
from eventlet.timeout import Timeout
from eventlet import TimeoutError
from webob import Request, Response
from webob.exc import HTTPAccepted, HTTPBadRequest, HTTPConflict, \
HTTPCreated, HTTPException, HTTPInternalServerError, HTTPNoContent, \
HTTPCreated, HTTPInternalServerError, HTTPNoContent, \
HTTPNotFound, HTTPPreconditionFailed, HTTPMethodNotAllowed
from swift.common.db import ContainerBroker
from swift.common.utils import get_logger, get_param, hash_path, \
storage_directory, split_path, mkdirs
storage_directory, split_path
from swift.common.constraints import CONTAINER_LISTING_LIMIT, \
check_mount, check_float, check_xml_encodable
from swift.common.bufferedhttp import http_connect
from swift.common.healthcheck import healthcheck
from swift.common.exceptions import ConnectionTimeout, MessageTimeout
from swift.common.exceptions import ConnectionTimeout
from swift.common.db_replicator import ReplicatorRpc
DATADIR = 'containers'

View File

@ -13,11 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import errno
import logging
import os
import signal
import socket
import sys
import time
from random import random, shuffle
@ -67,7 +65,6 @@ class ContainerUpdater(object):
:returns: a list of paths
"""
paths = []
ips = whataremyips()
for device in os.listdir(self.devices):
dev_path = os.path.join(self.devices, device)
if self.mount_check and not os.path.ismount(dev_path):

View File

@ -13,10 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import cPickle as pickle
import os
import socket
import sys
import time
from hashlib import md5
from random import choice, random
@ -71,7 +69,6 @@ class ObjectAuditor(object):
time.sleep(random() * self.interval)
while True:
begin = time.time()
pids = []
# read from container ring to ensure it's fresh
self.get_container_ring().get_nodes('')
for device in os.listdir(self.devices):
@ -192,7 +189,6 @@ class ObjectAuditor(object):
resp = conn.getresponse()
body = resp.read()
if 200 <= resp.status <= 299:
good_reponse = True
for oname in body.split('\n'):
if oname == obj:
found = True

View File

@ -14,9 +14,7 @@
# limitations under the License.
import os
import sys
from os.path import isdir, join
from ConfigParser import ConfigParser
import random
import shutil
import time
@ -385,7 +383,7 @@ class ObjectReplicator(object):
remote_hash.get(suffix, -1)]
if not suffixes:
continue
success = self.rsync(node, job, suffixes)
self.rsync(node, job, suffixes)
recalculate_hashes(job['path'], suffixes,
reclaim_age=self.reclaim_age)
with Timeout(60):
@ -409,7 +407,6 @@ class ObjectReplicator(object):
"""
if self.replication_count:
rate = self.replication_count / (time.time() - self.start)
left = int((self.job_count - self.replication_count) / rate)
self.logger.info("%d/%d (%.2f%%) partitions replicated in %.2f "
"seconds (%.2f/sec, %s remaining)"
% (self.replication_count, self.job_count,

View File

@ -19,7 +19,6 @@ from __future__ import with_statement
import cPickle as pickle
import errno
import os
import socket
import time
import traceback
from datetime import datetime
@ -30,13 +29,12 @@ from contextlib import contextmanager
from webob import Request, Response, UTC
from webob.exc import HTTPAccepted, HTTPBadRequest, HTTPCreated, \
HTTPInternalServerError, HTTPLengthRequired, HTTPNoContent, HTTPNotFound, \
HTTPNotImplemented, HTTPNotModified, HTTPPreconditionFailed, \
HTTPInternalServerError, HTTPNoContent, HTTPNotFound, \
HTTPNotModified, HTTPPreconditionFailed, \
HTTPRequestTimeout, HTTPUnprocessableEntity, HTTPMethodNotAllowed
from xattr import getxattr, setxattr
from eventlet import sleep, Timeout
from swift.common.exceptions import MessageTimeout
from swift.common.utils import mkdirs, normalize_timestamp, \
storage_directory, hash_path, get_logger, renamer, fallocate, \
split_path, drop_buffer_cache
@ -331,12 +329,12 @@ class ObjectController(object):
return Response(status='507 %s is not mounted' % device)
file = DiskFile(self.devices, device, partition, account, container,
obj, disk_chunk_size=self.disk_chunk_size)
deleted = file.is_deleted()
if file.is_deleted():
response_class = HTTPNotFound
else:
response_class = HTTPAccepted
old_metadata = file.metadata
metadata = {'X-Timestamp': request.headers['x-timestamp']}
metadata.update(val for val in request.headers.iteritems()
if val[0].lower().startswith('x-object-meta-'))

View File

@ -14,8 +14,6 @@
# limitations under the License.
import cPickle as pickle
import errno
import logging
import os
import signal
import sys
@ -28,7 +26,6 @@ from swift.common.bufferedhttp import http_connect
from swift.common.exceptions import ConnectionTimeout
from swift.common.ring import Ring
from swift.common.utils import get_logger, renamer
from swift.common.db_replicator import ReplConnection
from swift.obj.server import ASYNCDIR
@ -149,7 +146,7 @@ class ObjectUpdater(object):
"""
try:
update = pickle.load(open(update_path, 'rb'))
except Exception, err:
except Exception:
self.logger.exception(
'ERROR Pickle problem, quarantining %s' % update_path)
renamer(update_path, os.path.join(device,

View File

@ -14,22 +14,18 @@
# limitations under the License.
from __future__ import with_statement
import errno
import mimetypes
import os
import socket
import time
from ConfigParser import ConfigParser, NoOptionError
from ConfigParser import ConfigParser
from urllib import unquote, quote
import uuid
import sys
import functools
from eventlet.timeout import Timeout
from webob.exc import HTTPAccepted, HTTPBadRequest, HTTPConflict, \
HTTPCreated, HTTPLengthRequired, HTTPMethodNotAllowed, HTTPNoContent, \
HTTPNotFound, HTTPNotModified, HTTPPreconditionFailed, \
HTTPRequestTimeout, HTTPServiceUnavailable, HTTPUnauthorized, \
from webob.exc import HTTPBadRequest, HTTPMethodNotAllowed, \
HTTPNotFound, HTTPPreconditionFailed, \
HTTPRequestTimeout, HTTPServiceUnavailable, \
HTTPUnprocessableEntity, HTTPRequestEntityTooLarge, HTTPServerError, \
status_map
from webob import Request, Response

View File

@ -40,11 +40,12 @@ class TestObjectHandoff(unittest.TestCase):
container = 'container-%s' % uuid4()
client.put_container(self.url, self.token, container)
apart, anodes = self.account_ring.get_nodes(self.account)
anode = anodes[0]
cpart, cnodes = self.container_ring.get_nodes(self.account, container)
cnode = cnodes[0]
obj = 'object-%s' % uuid4()
opart, onodes = self.object_ring.get_nodes(self.account, container, obj)
opart, onodes = self.object_ring.get_nodes(
self.account, container, obj)
onode = onodes[0]
kill(self.pids[self.port2server[onode['port']]], SIGTERM)
client.put_object(self.url, self.token, container, obj, 'VERIFY')
@ -126,7 +127,8 @@ class TestObjectHandoff(unittest.TestCase):
kill(self.pids[self.port2server[onode['port']]], SIGTERM)
client.post_object(self.url, self.token, container, obj,
{'probe': 'value'})
ometadata = client.head_object(self.url, self.token, container, obj)[-1]
ometadata = client.head_object(
self.url, self.token, container, obj)[-1]
if ometadata.get('probe') != 'value':
raise Exception('Metadata incorrect, was %s' % repr(ometadata))
exc = False
@ -180,8 +182,8 @@ class TestObjectHandoff(unittest.TestCase):
raise Exception('Container listing still knew about object')
for cnode in cnodes:
objs = [o['name'] for o in
direct_client.direct_get_container(cnode, cpart,
self.account, container)]
direct_client.direct_get_container(
cnode, cpart, self.account, container)]
if obj in objs:
raise Exception(
'Container server %s:%s still knew about object' %