mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-06 09:57:57 +00:00
Tabs, meet your new overlords: spaces
In a quest to reach pep8, use spaces to indent rather than tabs.
This commit is contained in:
@ -15,54 +15,54 @@ from optparse import OptionParser
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = OptionParser()
|
||||
parser.add_option("-k", "--key", dest="key")
|
||||
parser.add_option("-u", "--user", dest="user")
|
||||
parser.add_option("-f", "--first", dest="first")
|
||||
parser.add_option("-l", "--last", dest="last")
|
||||
parser.add_option("-e", "--email", dest="email")
|
||||
parser.add_option("-s", "--suburl", dest="suburl")
|
||||
parser = OptionParser()
|
||||
parser.add_option("-k", "--key", dest="key")
|
||||
parser.add_option("-u", "--user", dest="user")
|
||||
parser.add_option("-f", "--first", dest="first")
|
||||
parser.add_option("-l", "--last", dest="last")
|
||||
parser.add_option("-e", "--email", dest="email")
|
||||
parser.add_option("-s", "--suburl", dest="suburl")
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if len(args) != 0:
|
||||
parser.print_usage()
|
||||
sys.exit(1)
|
||||
if len(args) != 0:
|
||||
parser.print_usage()
|
||||
sys.exit(1)
|
||||
|
||||
if not options.key:
|
||||
options.key = raw_input("Enter key (BASE64 encoded): ")
|
||||
if not options.user:
|
||||
options.user = raw_input("Enter username: ")
|
||||
if not options.first:
|
||||
options.first = "FirstName"
|
||||
if not options.last:
|
||||
options.last = "LastName"
|
||||
if not options.email:
|
||||
options.email = "test@example.com"
|
||||
if not options.key:
|
||||
options.key = raw_input("Enter key (BASE64 encoded): ")
|
||||
if not options.user:
|
||||
options.user = raw_input("Enter username: ")
|
||||
if not options.first:
|
||||
options.first = "FirstName"
|
||||
if not options.last:
|
||||
options.last = "LastName"
|
||||
if not options.email:
|
||||
options.email = "test@example.com"
|
||||
|
||||
# This is basically a rip of the view in accounts/views.py
|
||||
info = {
|
||||
'u': options.user,
|
||||
'f': options.first,
|
||||
'l': options.last,
|
||||
'e': options.email,
|
||||
}
|
||||
if options.suburl:
|
||||
info['su'] = options.suburl
|
||||
# This is basically a rip of the view in accounts/views.py
|
||||
info = {
|
||||
'u': options.user,
|
||||
'f': options.first,
|
||||
'l': options.last,
|
||||
'e': options.email,
|
||||
}
|
||||
if options.suburl:
|
||||
info['su'] = options.suburl
|
||||
|
||||
# Turn this into an URL. Make sure the timestamp is always first, that makes
|
||||
# the first block more random..
|
||||
# Since this is a fake authentication, put it 5 minutes into the future to
|
||||
# give more time to copy/paste it.
|
||||
s = "t=%s&%s" % (int(time.time()+300), urllib.urlencode(info))
|
||||
# Turn this into an URL. Make sure the timestamp is always first, that makes
|
||||
# the first block more random..
|
||||
# Since this is a fake authentication, put it 5 minutes into the future to
|
||||
# give more time to copy/paste it.
|
||||
s = "t=%s&%s" % (int(time.time()+300), urllib.urlencode(info))
|
||||
|
||||
r = Random.new()
|
||||
iv = r.read(16)
|
||||
encryptor = AES.new(base64.b64decode(options.key), AES.MODE_CBC, iv)
|
||||
cipher = encryptor.encrypt(s + ' ' * (16-(len(s) % 16)))
|
||||
r = Random.new()
|
||||
iv = r.read(16)
|
||||
encryptor = AES.new(base64.b64decode(options.key), AES.MODE_CBC, iv)
|
||||
cipher = encryptor.encrypt(s + ' ' * (16-(len(s) % 16)))
|
||||
|
||||
print "Paste the following after the receiving url:"
|
||||
print "?i=%s&d=%s" % (
|
||||
base64.b64encode(iv, "-_"),
|
||||
base64.b64encode(cipher, "-_"),
|
||||
)
|
||||
print "Paste the following after the receiving url:"
|
||||
print "?i=%s&d=%s" % (
|
||||
base64.b64encode(iv, "-_"),
|
||||
base64.b64encode(cipher, "-_"),
|
||||
)
|
||||
|
Reference in New Issue
Block a user