from winsys import dialogs name = dialogs.dialog ("What is your name?", ("Name", ""))
from winsys import dialogs, registry root, term = dialogs.dialog ( "Search the Registry", ("Root", registry.REGISTRY_HIVE.keys ()), ("Term", "") ) root = registry.registry (root) term = term.lower () for key, subkeys, values in root.walk (ignore_access_errors=True): for name, value in values: if term in str (value).lower (): print key.moniker.encode ("utf8") print name.encode ("utf8") or "(Default)" print unicode (value).encode ("utf8") print
from winsys import dialogs, security [filename] = dialogs.dialog("Choose file", ("Filename", "")) security.security(filename).dump()
import os import csv from winsys import event_logs, dialogs def remote_events(computer, event_source, event_type_id): for event in event_logs.event_log(r"\\%s\system" % computer): if event.source_name.upper( ) == event_source and event.event_type == event_type_id: yield event computer, event_source, (event_type_name, event_type_id) = dialogs.dialog( "Computer", ("Computer Name", "."), ("Event Source", "DHCP"), ("Event Type", event_logs.EVENTLOG_TYPE.items())) csv.writer(open("dhcp.csv", "wb")).writerows( (event.record_number, event.time_generated, event.event_id, event.message) for event in remote_events(computer, event_source.upper(), event_type_id)) os.startfile("dhcp.csv")
import operator from winsys import dialogs, fs, utils [root] = dialogs.dialog( "Find top-level sizes", ("Start from", "", dialogs.get_folder) ) sizes = dict( (d, sum(f.size for f in d.flat())) for d in fs.dir(root).dirs() ) for d, size in sorted(sizes.items(), key=operator.itemgetter(1), reverse=True): print d.name, "=>", utils.size_as_mb(size)
#!python3 import os, sys print(sys.executable) from winsys import fs, dialogs print(dialogs.dialog("abc", ("def", ["1", "2", "3"])))
from __future__ import with_statement import os import csv from winsys import dialogs, event_logs log_name, filename = dialogs.dialog( "Write event log to csv", ("Event log", list(event_logs.event_logs())), ("CSV filename", ""), ) namer = event_logs.EVENTLOG_TYPE.name_from_value with open(filename, "wb") as f: csv.writer(f).writerows( (e.time_generated, e.source_name, namer(e.event_type), e.message) for e in event_logs.event_log(log_name)) os.startfile(filename)
import os import csv from winsys import event_logs, dialogs def remote_events (computer, event_source, event_type_id): for event in event_logs.event_log (r"\\%s\system" % computer): if event.source_name.upper () == event_source and event.event_type == event_type_id: yield event computer, event_source, (event_type_name, event_type_id) = dialogs.dialog ( "Computer", ("Computer Name", "."), ("Event Source", "DHCP"), ("Event Type", event_logs.EVENTLOG_TYPE.items ()) ) csv.writer (open ("dhcp.csv", "wb")).writerows ( (event.record_number, event.time_generated, event.event_id, event.message) for event in remote_events (computer, event_source.upper (), event_type_id) ) os.startfile ("dhcp.csv")
from __future__ import with_statement import os import csv from winsys import dialogs, event_logs log_name, filename = dialogs.dialog( "Write event log to csv", ("Event log", list(event_logs.event_logs())), ("CSV filename", ""), ) namer = event_logs.EVENTLOG_TYPE.name_from_value with open(filename, "wb") as f: csv.writer(f).writerows( (e.time_generated, e.source_name, namer(e.event_type), e.message) for e in event_logs.event_log(log_name) ) os.startfile(filename)
import os from winsys import dialogs, fs DEFAULT = "temp.csv" filename, = dialogs.dialog ( "Open a filename", ("Filename", DEFAULT, dialogs.get_filename) ) if not fs.file (filename): raise RuntimeError ("%s does not exist" % filename) else: os.startfile (filename)
import os from winsys import dialogs, fs DEFAULT = "temp.csv" filename, = dialogs.dialog( "Open a filename", ("Filename", DEFAULT, dialogs.get_filename) ) if not fs.file(filename): raise RuntimeError("%s does not exist" % filename) else: os.startfile(filename)
from winsys import dialogs name = dialogs.dialog("What is your name?", ("Name", ""))
import operator from winsys import dialogs, fs, utils [root] = dialogs.dialog("Find top-level sizes", ("Start from", "", dialogs.get_folder)) sizes = dict((d, sum(f.size for f in d.flat())) for d in fs.dir(root).dirs()) for d, size in sorted(sizes.items(), key=operator.itemgetter(1), reverse=True): print d.name, "=>", utils.size_as_mb(size)