mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-19 13:07:56 +00:00
Merge pull request #740 from tahoe-lafs/3340-unused-code-in-util
Delete some dead code. Fixes: ticket:3340
This commit is contained in:
commit
c493396148
0
newsfragments/3340.other
Normal file
0
newsfragments/3340.other
Normal file
@ -1,6 +1,6 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import os, signal, sys, time
|
||||
import os, signal, time
|
||||
from random import randrange
|
||||
from six.moves import StringIO
|
||||
|
||||
@ -8,7 +8,6 @@ from twisted.internet import reactor, defer
|
||||
from twisted.python import failure
|
||||
from twisted.trial import unittest
|
||||
|
||||
from allmydata.util import fileutil, log
|
||||
from ..util.assertutil import precondition
|
||||
from allmydata.util.encodingutil import (unicode_platform, get_filesystem_encoding,
|
||||
get_io_encoding)
|
||||
@ -89,39 +88,6 @@ class ReallyEqualMixin(object):
|
||||
self.assertEqual(type(a), type(b), "a :: %r, b :: %r, %r" % (a, b, msg))
|
||||
|
||||
|
||||
class NonASCIIPathMixin(object):
|
||||
def mkdir_nonascii(self, dirpath):
|
||||
# Kludge to work around the fact that buildbot can't remove a directory tree that has
|
||||
# any non-ASCII directory names on Windows. (#1472)
|
||||
if sys.platform == "win32":
|
||||
def _cleanup():
|
||||
try:
|
||||
fileutil.rm_dir(dirpath)
|
||||
finally:
|
||||
if os.path.exists(dirpath):
|
||||
msg = ("We were unable to delete a non-ASCII directory %r created by the test. "
|
||||
"This is liable to cause failures on future builds." % (dirpath,))
|
||||
print(msg)
|
||||
log.err(msg)
|
||||
self.addCleanup(_cleanup)
|
||||
os.mkdir(dirpath)
|
||||
|
||||
def unicode_or_fallback(self, unicode_name, fallback_name, io_as_well=False):
|
||||
if not unicode_platform():
|
||||
try:
|
||||
unicode_name.encode(get_filesystem_encoding())
|
||||
except UnicodeEncodeError:
|
||||
return fallback_name
|
||||
|
||||
if io_as_well:
|
||||
try:
|
||||
unicode_name.encode(get_io_encoding())
|
||||
except UnicodeEncodeError:
|
||||
return fallback_name
|
||||
|
||||
return unicode_name
|
||||
|
||||
|
||||
class SignalMixin(object):
|
||||
# This class is necessary for any code which wants to use Processes
|
||||
# outside the usual reactor.run() environment. It is copied from
|
||||
|
@ -83,7 +83,7 @@ BASECONFIG_I = ("[client]\n"
|
||||
"introducer.furl = %s\n"
|
||||
)
|
||||
|
||||
class Basic(testutil.ReallyEqualMixin, testutil.NonASCIIPathMixin, unittest.TestCase):
|
||||
class Basic(testutil.ReallyEqualMixin, unittest.TestCase):
|
||||
def test_loadable(self):
|
||||
basedir = "test_client.Basic.test_loadable"
|
||||
os.mkdir(basedir)
|
||||
|
@ -12,7 +12,7 @@ from errno import ENOENT
|
||||
if sys.platform == "win32":
|
||||
from ctypes import WINFUNCTYPE, WinError, windll, POINTER, byref, c_ulonglong, \
|
||||
create_unicode_buffer, get_last_error
|
||||
from ctypes.wintypes import BOOL, DWORD, LPCWSTR, LPWSTR, LPVOID, HANDLE
|
||||
from ctypes.wintypes import BOOL, DWORD, LPCWSTR, LPWSTR, LPVOID
|
||||
|
||||
from twisted.python import log
|
||||
|
||||
@ -538,60 +538,6 @@ def get_available_space(whichdir, reserved_space):
|
||||
return 0
|
||||
|
||||
|
||||
if sys.platform == "win32":
|
||||
# <http://msdn.microsoft.com/en-us/library/aa363858%28v=vs.85%29.aspx>
|
||||
CreateFileW = WINFUNCTYPE(
|
||||
HANDLE, LPCWSTR, DWORD, DWORD, LPVOID, DWORD, DWORD, HANDLE,
|
||||
use_last_error=True
|
||||
)(("CreateFileW", windll.kernel32))
|
||||
|
||||
GENERIC_WRITE = 0x40000000
|
||||
FILE_SHARE_READ = 0x00000001
|
||||
FILE_SHARE_WRITE = 0x00000002
|
||||
OPEN_EXISTING = 3
|
||||
INVALID_HANDLE_VALUE = 0xFFFFFFFF
|
||||
|
||||
# <http://msdn.microsoft.com/en-us/library/aa364439%28v=vs.85%29.aspx>
|
||||
FlushFileBuffers = WINFUNCTYPE(
|
||||
BOOL, HANDLE,
|
||||
use_last_error=True
|
||||
)(("FlushFileBuffers", windll.kernel32))
|
||||
|
||||
# <http://msdn.microsoft.com/en-us/library/ms724211%28v=vs.85%29.aspx>
|
||||
CloseHandle = WINFUNCTYPE(
|
||||
BOOL, HANDLE,
|
||||
use_last_error=True
|
||||
)(("CloseHandle", windll.kernel32))
|
||||
|
||||
# <http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/4465cafb-f4ed-434f-89d8-c85ced6ffaa8/>
|
||||
def flush_volume(path):
|
||||
abspath = os.path.realpath(path)
|
||||
if abspath.startswith("\\\\?\\"):
|
||||
abspath = abspath[4 :]
|
||||
drive = os.path.splitdrive(abspath)[0]
|
||||
|
||||
print("flushing %r" % (drive,))
|
||||
hVolume = CreateFileW(u"\\\\.\\" + drive,
|
||||
GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
None,
|
||||
OPEN_EXISTING,
|
||||
0,
|
||||
None
|
||||
)
|
||||
if hVolume == INVALID_HANDLE_VALUE:
|
||||
raise WinError(get_last_error())
|
||||
|
||||
if FlushFileBuffers(hVolume) == 0:
|
||||
raise WinError(get_last_error())
|
||||
|
||||
CloseHandle(hVolume)
|
||||
else:
|
||||
def flush_volume(path):
|
||||
# use sync()?
|
||||
pass
|
||||
|
||||
|
||||
class ConflictError(Exception):
|
||||
pass
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
from twisted.internet import address
|
||||
from foolscap.api import Violation, RemoteException, DeadReferenceError, \
|
||||
SturdyRef
|
||||
from foolscap.api import Violation, RemoteException, SturdyRef
|
||||
|
||||
|
||||
def add_version_to_remote_reference(rref, default):
|
||||
"""I try to add a .version attribute to the given RemoteReference. I call
|
||||
@ -19,12 +19,6 @@ def add_version_to_remote_reference(rref, default):
|
||||
d.addCallbacks(_got_version, _no_get_version)
|
||||
return d
|
||||
|
||||
def trap_and_discard(f, *errorTypes):
|
||||
f.trap(*errorTypes)
|
||||
|
||||
def trap_deadref(f):
|
||||
return trap_and_discard(f, DeadReferenceError)
|
||||
|
||||
|
||||
def connection_hints_for_furl(furl):
|
||||
hints = []
|
||||
|
Loading…
Reference in New Issue
Block a user