PEP8 for bin directory
Closes-Bug: #1516754 Change-Id: I548cf0e86aee57ede32eace505468026ca871fcd
This commit is contained in:
parent
911adf7299
commit
b15e9637dc
@ -17,8 +17,8 @@
|
||||
from getpass import getpass
|
||||
import gettext
|
||||
from optparse import OptionParser
|
||||
from os.path import basename
|
||||
from sys import argv, exit
|
||||
from sys import argv
|
||||
from sys import exit
|
||||
|
||||
from swift.common.bufferedhttp import http_connect_raw as http_connect
|
||||
from swift.common.utils import urlparse
|
||||
|
@ -17,8 +17,8 @@
|
||||
from getpass import getpass
|
||||
import gettext
|
||||
from optparse import OptionParser
|
||||
from os.path import basename
|
||||
from sys import argv, exit
|
||||
from sys import argv
|
||||
from sys import exit
|
||||
|
||||
from swift.common.bufferedhttp import http_connect_raw as http_connect
|
||||
from swift.common.utils import urlparse
|
||||
@ -81,11 +81,12 @@ if __name__ == '__main__':
|
||||
resp = conn.getresponse()
|
||||
if resp.status // 100 != 2:
|
||||
headers['Content-Length'] = '0'
|
||||
conn = http_connect(parsed.hostname, parsed.port, 'PUT', path, headers,
|
||||
ssl=(parsed.scheme == 'https'))
|
||||
conn = http_connect(parsed.hostname, parsed.port, 'PUT', path,
|
||||
headers, ssl=(parsed.scheme == 'https'))
|
||||
resp = conn.getresponse()
|
||||
if resp.status // 100 != 2:
|
||||
print('Account creation failed: %s %s' % (resp.status, resp.reason))
|
||||
print('Account creation failed: %s %s' %
|
||||
(resp.status, resp.reason))
|
||||
# Add the user
|
||||
path = '%sv2/%s/%s' % (parsed_path, account, user)
|
||||
headers = {'X-Auth-Admin-User': options.admin_user,
|
||||
|
@ -14,19 +14,23 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
try:
|
||||
import simplejson as json
|
||||
except ImportError:
|
||||
import json
|
||||
from getpass import getpass
|
||||
import gettext
|
||||
import re
|
||||
from datetime import datetime, timedelta
|
||||
from optparse import OptionParser
|
||||
from sys import argv, exit
|
||||
from time import sleep, time
|
||||
import re
|
||||
from sys import argv
|
||||
from sys import exit
|
||||
from time import sleep
|
||||
from time import time
|
||||
|
||||
from swiftclient.client import Connection, ClientException
|
||||
from swiftclient.client import ClientException
|
||||
from swiftclient.client import Connection
|
||||
|
||||
if __name__ == '__main__':
|
||||
gettext.install('swauth', unicode=1)
|
||||
@ -86,12 +90,12 @@ if __name__ == '__main__':
|
||||
token = headers['x-object-meta-auth-token']
|
||||
container = '.token_%s' % token[-1]
|
||||
if options.verbose:
|
||||
print('%s/%s purge account %r; deleting' % \
|
||||
print('%s/%s purge account %r; deleting' %
|
||||
(container, token, options.purge_account))
|
||||
print('DELETE %s/%s' % (container, token))
|
||||
try:
|
||||
conn.delete_object(container, token)
|
||||
except ClientException, err:
|
||||
except ClientException as err:
|
||||
if err.http_status != 404:
|
||||
raise
|
||||
continue
|
||||
@ -106,7 +110,7 @@ if __name__ == '__main__':
|
||||
print('GET %s?marker=%s' % (container, marker))
|
||||
try:
|
||||
objs = conn.get_container(container, marker=marker)[1]
|
||||
except ClientException, e:
|
||||
except ClientException as e:
|
||||
if e.http_status == 404:
|
||||
exit('Container %s not found. swauth-prep needs to be '
|
||||
'rerun' % (container))
|
||||
@ -122,12 +126,12 @@ if __name__ == '__main__':
|
||||
for obj in objs:
|
||||
if options.purge_all:
|
||||
if options.verbose:
|
||||
print('%s/%s purge all; deleting' % \
|
||||
print('%s/%s purge all; deleting' %
|
||||
(container, obj['name']))
|
||||
print('DELETE %s/%s' % (container, obj['name']))
|
||||
try:
|
||||
conn.delete_object(container, obj['name'])
|
||||
except ClientException, err:
|
||||
except ClientException as err:
|
||||
if err.http_status != 404:
|
||||
raise
|
||||
continue
|
||||
@ -136,7 +140,7 @@ if __name__ == '__main__':
|
||||
ago = datetime.utcnow() - last_modified
|
||||
if ago > options.token_life:
|
||||
if options.verbose:
|
||||
print('%s/%s last modified %ss ago; investigating' % \
|
||||
print('%s/%s last modified %ss ago; investigating' %
|
||||
(container, obj['name'],
|
||||
ago.days * 86400 + ago.seconds))
|
||||
print('GET %s/%s' % (container, obj['name']))
|
||||
@ -144,23 +148,23 @@ if __name__ == '__main__':
|
||||
detail = json.loads(detail)
|
||||
if detail['expires'] < time():
|
||||
if options.verbose:
|
||||
print('%s/%s expired %ds ago; deleting' % \
|
||||
print('%s/%s expired %ds ago; deleting' %
|
||||
(container, obj['name'],
|
||||
time() - detail['expires']))
|
||||
print('DELETE %s/%s' % (container, obj['name']))
|
||||
try:
|
||||
conn.delete_object(container, obj['name'])
|
||||
except ClientException, e:
|
||||
except ClientException as e:
|
||||
if e.http_status != 404:
|
||||
print('DELETE of %s/%s failed with status ' \
|
||||
print('DELETE of %s/%s failed with status '
|
||||
'code %d' % (container, obj['name'],
|
||||
e.http_status))
|
||||
elif options.verbose:
|
||||
print("%s/%s won't expire for %ds; skipping" % \
|
||||
print("%s/%s won't expire for %ds; skipping" %
|
||||
(container, obj['name'],
|
||||
detail['expires'] - time()))
|
||||
elif options.verbose:
|
||||
print('%s/%s last modified %ss ago; skipping' % \
|
||||
print('%s/%s last modified %ss ago; skipping' %
|
||||
(container, obj['name'],
|
||||
ago.days * 86400 + ago.seconds))
|
||||
sleep(options.sleep)
|
||||
|
@ -17,8 +17,8 @@
|
||||
from getpass import getpass
|
||||
import gettext
|
||||
from optparse import OptionParser
|
||||
from os.path import basename
|
||||
from sys import argv, exit
|
||||
from sys import argv
|
||||
from sys import exit
|
||||
|
||||
from swift.common.bufferedhttp import http_connect_raw as http_connect
|
||||
from swift.common.utils import urlparse
|
||||
|
@ -17,8 +17,8 @@
|
||||
from getpass import getpass
|
||||
import gettext
|
||||
from optparse import OptionParser
|
||||
from os.path import basename
|
||||
from sys import argv, exit
|
||||
from sys import argv
|
||||
from sys import exit
|
||||
|
||||
from swift.common.bufferedhttp import http_connect_raw as http_connect
|
||||
from swift.common.utils import urlparse
|
||||
|
@ -21,8 +21,8 @@ except ImportError:
|
||||
from getpass import getpass
|
||||
import gettext
|
||||
from optparse import OptionParser
|
||||
from os.path import basename
|
||||
from sys import argv, exit
|
||||
from sys import argv
|
||||
from sys import exit
|
||||
|
||||
from swift.common.bufferedhttp import http_connect_raw as http_connect
|
||||
from swift.common.utils import urlparse
|
||||
|
@ -17,8 +17,8 @@
|
||||
from getpass import getpass
|
||||
import gettext
|
||||
from optparse import OptionParser
|
||||
from os.path import basename
|
||||
from sys import argv, exit
|
||||
from sys import argv
|
||||
from sys import exit
|
||||
|
||||
from swift.common.bufferedhttp import http_connect_raw as http_connect
|
||||
from swift.common.utils import urlparse
|
||||
|
@ -21,8 +21,8 @@ except ImportError:
|
||||
from getpass import getpass
|
||||
import gettext
|
||||
from optparse import OptionParser
|
||||
from os.path import basename
|
||||
from sys import argv, exit
|
||||
from sys import argv
|
||||
from sys import exit
|
||||
|
||||
from swift.common.bufferedhttp import http_connect_raw as http_connect
|
||||
from swift.common.utils import urlparse
|
||||
@ -35,7 +35,8 @@ Usage: %prog [options] <account> <service> <name> <value>
|
||||
|
||||
Sets a service URL for an account. Can only be set by a reseller admin.
|
||||
|
||||
Example: %prog -K swauthkey test storage local http://127.0.0.1:8080/v1/AUTH_018c3946-23f8-4efb-a8fb-b67aae8e4162
|
||||
Example: %prog -K swauthkey test storage local
|
||||
http://127.0.0.1:8080/v1/AUTH_018c3946-23f8-4efb-a8fb-b67aae8e4162
|
||||
'''.strip())
|
||||
parser.add_option('-A', '--admin-url', dest='admin_url',
|
||||
default='http://127.0.0.1:8080/auth/', help='The URL to the auth '
|
||||
|
Loading…
x
Reference in New Issue
Block a user