Remove dead code no longer used

Change-Id: Ib9b04fada864545f0cf8ec96ea0ef56ca5f79b7d
This commit is contained in:
Joshua Harlow 2015-07-07 22:21:39 -07:00
parent 5193dc0cf5
commit 854a63e558
4 changed files with 0 additions and 218 deletions

View File

@ -1,81 +0,0 @@
# Copyright (C) 2014 Yahoo! Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import time
# Various useful decorators...
#
# Copyright 2011 Christopher Arndt, MIT License
#
# https://wiki.python.org/moin/PythonDecoratorLibrary#Cached_Properties
# pylint: disable=C0103
class cached_property(object):
'''Decorator for read-only properties evaluated only once within TTL period.
It can be used to created a cached property like this::
import random
# the class containing the property must be a new-style class
class MyClass(object):
# create property whose value is cached for ten minutes
@cached_property(ttl=600)
def randint(self):
# will only be evaluated every 10 min. at maximum.
return random.randint(0, 100)
The value is cached in the '_cache' attribute of the object instance that
has the property getter method wrapped by this decorator. The '_cache'
attribute value is a dictionary which has a key for every property of the
object which is wrapped by this decorator. Each entry in the cache is
created only when the property is accessed for the first time and is a
two-element tuple with the last computed property value and the last time
it was updated in seconds since the epoch.
The default time-to-live (TTL) is 300 seconds (5 minutes). Set the TTL to
zero for the cached value to never expire.
To expire a cached property value manually just do::
del instance._cache[<property name>]
'''
def __init__(self, ttl=300):
self.ttl = ttl
self.fget = None
def __call__(self, fget, doc=None):
self.fget = fget
self.__doc__ = doc or fget.__doc__ # pylint: disable=W0201
self.__name__ = fget.__name__ # pylint: disable=W0201
self.__module__ = fget.__module__ # pylint: disable=W0201
return self
def __get__(self, inst, owner):
now = time.time()
try:
value, last_update = inst._cache[self.__name__]
if self.ttl > 0 and now - last_update > self.ttl:
raise AttributeError
except (KeyError, AttributeError):
value = self.fget(inst)
try:
cache = inst._cache
except AttributeError:
cache = inst._cache = {}
cache[self.__name__] = (value, now)
return value

View File

@ -1,16 +0,0 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright (C) 2012 Yahoo! Inc. All Rights Reserved.
# Copyright (C) 2012 New Dream Network, LLC (DreamHost) All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

View File

@ -241,12 +241,6 @@ def pipe_in_out(in_fh, out_fh, chunk_size=1024, chunk_cb=None):
return bytes_piped
def shellquote(text):
if text.isalnum():
return text
return "'%s'" % text.replace("'", "'\\''")
def fileperms(path):
return (os.stat(path).st_mode & 0o777)
@ -478,22 +472,6 @@ def symlink(source, link, force=True, tracewriter=None):
tracewriter.symlink_made(link)
def user_exists(username):
all_users = pwd.getpwall()
for info in all_users:
if info.pw_name == username:
return True
return False
def group_exists(grpname):
all_grps = grp.getgrall()
for info in all_grps:
if info.gr_name == grpname:
return True
return False
def getuser():
(uid, _gid) = get_suids()
if uid is None:

View File

@ -29,7 +29,6 @@ import socket
import sys
import tempfile
import time
import urllib2
try:
# Only in python 2.7+
@ -39,8 +38,6 @@ except ImportError:
from datetime import datetime
from urlparse import urlunparse
import netifaces
import progressbar
import six
@ -57,21 +54,6 @@ from anvil import version
from anvil.pprint import center_text
# Message queue types to there internal 'canonicalized' name
MQ_TYPES = {
'qpid': 'qpid',
'qpidd': 'qpid',
'rabbit': 'rabbit',
'rabbit-mq': 'rabbit',
}
# Virt 'canonicalized' name to there computer driver name
VIRT_DRIVER_MAP = {
'libvirt': 'libvirt.LibvirtDriver',
'xenserver': 'xenapi.XenAPIDriver',
'vmware': 'vmwareapi.VMWareESXDriver',
'baremetal': 'baremetal.BareMetalDriver',
}
MONTY_PYTHON_TEXT_RE = re.compile(r"([a-z0-9A-Z\?!.,'\"]+)")
@ -211,54 +193,6 @@ def has_any(text, *look_for):
return False
def wait_for_url(url, max_attempts=5,
on_start=None, on_wait=None, on_success=None):
if max_attempts <= 0:
raise ValueError("Wait maximum attempts must be > 0")
def log_start():
LOG.info("Waiting for url %s to become active (max_attempts=%s)",
colorizer.quote(url), max_attempts)
def log_wait(sleep_secs):
LOG.info("Sleeping for %s seconds, %s is still not active.", sleep_secs, colorizer.quote(url))
return sleep_secs
def log_success(attempts):
LOG.info("Url %s became active after %s attempts!", colorizer.quote(url), attempts)
if not on_wait:
on_wait = log_wait
if not on_success:
on_success = log_success
if not on_start:
on_start = log_start
failures = []
for i, sleep_time in enumerate(ExponentialBackoff(attempts=max_attempts)):
if i == 0:
on_start()
try:
with contextlib.closing(urllib2.urlopen(urllib2.Request(url))) as req:
req.read()
on_success(i + 1)
return url
except urllib2.HTTPError as e:
failures.append(sys.exc_info())
if e.code in range(200, 600):
# Should be ok, at least its responding...
# although potentially incorrectly...
on_success(i + 1)
return url
else:
sh.sleep(on_wait(sleep_time))
except IOError:
failures.append(sys.exc_info())
sh.sleep(on_wait(sleep_time))
exc_type, exc, exc_tb = failures[-1]
six.reraise(exc_type, exc, exc_tb)
def retry(attempts, delay, func, *args, **kwargs):
if delay < 0:
raise ValueError("delay must be >= 0")
@ -379,27 +313,6 @@ def merge_dicts(*dicts, **kwargs):
return merged
def make_url(scheme, host, port=None, path='', params='', query='', fragment=''):
pieces = []
pieces.append(scheme or '')
netloc = ''
if host:
netloc = str(host)
if port is not None:
netloc += ":" + "%s" % (port)
pieces.append(netloc or '')
pieces.append(path or '')
pieces.append(params or '')
pieces.append(query or '')
pieces.append(fragment or '')
return urlunparse([str(p) for p in pieces])
def get_deep(items, path, quiet=True):
if len(path) == 0:
return items
@ -727,18 +640,6 @@ def splitlines_not_empty(text):
yield line
def canon_mq_type(mq_type):
mq_type = str(mq_type).lower().strip()
return MQ_TYPES.get(mq_type, 'rabbit')
def canon_virt_driver(virt_driver):
virt_driver = str(virt_driver).strip().lower()
if not (virt_driver in VIRT_DRIVER_MAP):
return 'libvirt'
return virt_driver
def strip_prefix_suffix(line, prefix=None, suffix=None):
if prefix and line.startswith(prefix):
line = line[len(prefix):]