make it somewhat portable
This commit is contained in:
parent
aedc80a555
commit
dba8a92d35
15
pw.py
15
pw.py
@ -4,24 +4,27 @@ import random
|
|||||||
|
|
||||||
def generate_pw(length):
|
def generate_pw(length):
|
||||||
import string
|
import string
|
||||||
charset = string.ascii_letters + string.digits + '+-_?!.:,;';
|
charset = string.ascii_letters + string.digits + '+-_?!.:,;'
|
||||||
return ''.join([random.choice(charset) for _ in range(length)])
|
return ''.join([random.choice(charset) for _ in range(length)])
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import win32clipboard
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
length = int(sys.argv[1])
|
length = int(sys.argv[1])
|
||||||
else:
|
else:
|
||||||
length = 12
|
length = 12
|
||||||
pw = generate_pw(length)
|
pw = generate_pw(length)
|
||||||
print(pw)
|
print(pw)
|
||||||
win32clipboard.OpenClipboard()
|
|
||||||
win32clipboard.EmptyClipboard()
|
if os.name == 'nt':
|
||||||
win32clipboard.SetClipboardText(pw, win32clipboard.CF_UNICODETEXT)
|
import win32clipboard
|
||||||
win32clipboard.CloseClipboard()
|
win32clipboard.OpenClipboard()
|
||||||
|
win32clipboard.EmptyClipboard()
|
||||||
|
win32clipboard.SetClipboardText(pw, win32clipboard.CF_UNICODETEXT)
|
||||||
|
win32clipboard.CloseClipboard()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user