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):
|
||||
import string
|
||||
charset = string.ascii_letters + string.digits + '+-_?!.:,;';
|
||||
charset = string.ascii_letters + string.digits + '+-_?!.:,;'
|
||||
return ''.join([random.choice(charset) for _ in range(length)])
|
||||
|
||||
def main():
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
import win32clipboard
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
length = int(sys.argv[1])
|
||||
else:
|
||||
length = 12
|
||||
pw = generate_pw(length)
|
||||
print(pw)
|
||||
win32clipboard.OpenClipboard()
|
||||
win32clipboard.EmptyClipboard()
|
||||
win32clipboard.SetClipboardText(pw, win32clipboard.CF_UNICODETEXT)
|
||||
win32clipboard.CloseClipboard()
|
||||
|
||||
if os.name == 'nt':
|
||||
import win32clipboard
|
||||
win32clipboard.OpenClipboard()
|
||||
win32clipboard.EmptyClipboard()
|
||||
win32clipboard.SetClipboardText(pw, win32clipboard.CF_UNICODETEXT)
|
||||
win32clipboard.CloseClipboard()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
Reference in New Issue
Block a user