forked from tilde/ssh-reg
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
880 B
Python
25 lines
880 B
Python
#!/usr/bin/env python3
|
|
|
|
from lib.sqlitedb import SQLitedb
|
|
import lib.CFG as CFG
|
|
import ListUsers, csv, os, io
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
L = ListUsers.ListUsers()
|
|
fetch = L.getFetch()
|
|
ret = io.StringIO()
|
|
writer = csv.writer(ret, quoting=csv.QUOTE_NONNUMERIC) # @TODO: Should be a specific dialect instead?
|
|
writer.writerow(['id', 'username', 'email', 'name', 'pubkey' 'timestamp', 'status'])
|
|
for user in fetch:
|
|
writer.writerow([user['id'], user['username'], user['email'], user['name'], user['pubkey'],
|
|
user['timestamp'], user['status']])
|
|
|
|
if CFG.args.file == "stdout":
|
|
print(ret.getvalue())
|
|
else:
|
|
with open(CFG.args.file, "w") as f:
|
|
print(ret.getvalue(), file=f)
|
|
exit(0)
|
|
except KeyboardInterrupt as e:
|
|
pass |