Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
', '.join(SAVE_FORMATS.keys())
), file=sys.stderr)
exit(1)
if save_as.exists():
print('Error: Path {0} already exists. Not overwriting'.format(save_as), file=sys.stderr)
exit(1)
with Timer(factor=1000) as t:
parsed = parse(text, stylesheets=css)
print('Parsed in {0:f} ms'.format(t.elapsed))
with Timer(factor=1000) as t:
try:
word = CreateObject("Word.Application")
except AttributeError as e:
gen_dir = inspect.getsourcefile(gen)
print('****** There was an error opening word ******')
print('This is a transient error that sometimes happens.')
print('Remove all files (except __init__.py) from here:')
print(os.path.dirname(gen_dir))
print('Then retry the program')
print('*********************************************')
raise e
doc = word.Documents.Add()
print('Opened word in {0:f} ms'.format(t.elapsed))
word.Visible = not arguments['--hidden']
def __init__(self, device="default"):
self.isAcquired=False
self._lastKnownCoords=(0,0)
self._lastContactCoords=(0,0)
self._lastContactTimestamp=0
self._fingerPresent=False
self._numFingers=0
self._fingerTimestamp=0
self._lastTapTimestamp=0
self.pad=CreateObject('SynCtrl.SynDeviceCtrl')
self.deviceHandle=None
self.packet=CreateObject('SynCtrl.SynPacketCtrl')
self.conn=GetEvents(self.pad, self)
log.info(self.api.GetStringProperty(synlib.SP_VersionString))
self._set_device(device)
#We do not need events until the device is acquired
self.pad.deactivate()
("dwReserved", c_int),
("flagsEx", c_int))
MB_YESNO = 0x4
MB_ICONQUESTION = 0x20
MB_ICONWARNING = 0x30
MB_ICONINFORMATION = 0x40
MB_DEFBUTTON2 = 0x100
IDYES = 6
IDNO = 7
from comtypes.client import CreateObject
ws = CreateObject("WScript.Shell")
from comtypes.gen import IWshRuntimeLibrary
_ = lambda s: s
def select_file_dialog():
ofx = OPENFILENAME()
ofx.lStructSize = ctypes.sizeof(OPENFILENAME)
ofx.nMaxFile = 1024
ofx.hwndOwner = 0
ofx.lpstrTitle = "Please select the Python interpreter executable"
opath = u"\0" * 1024
ofx.lpstrFile = opath
filters = ["Executables|*.exe; *.bat", "All Files|*.*"]
ofx.lpstrFilter = unicode("\0".join([f.replace("|", "\0") for f in filters])+"\0\0")
OFN_HIDEREADONLY = 4
ofx.flags = OFN_HIDEREADONLY
def __init__(self):
import comtypes.client
self.voice = comtypes.client.CreateObject("SAPI.SpVoice")
def _getWSH():
global _wsh
if not _wsh:
import comtypes.client
_wsh=comtypes.client.CreateObject("wScript.Shell",dynamic=True)
return _wsh
def save_to_file(self, text, filename):
cwd = os.getcwd()
stream = comtypes.client.CreateObject('SAPI.SPFileStream')
stream.Open(filename, SpeechLib.SSFMCreateForWrite)
temp_stream = self._tts.AudioOutputStream
self._tts.AudioOutputStream = stream
self._tts.Speak(fromUtf8(toUtf8(text)))
self._tts.AudioOutputStream = temp_stream
stream.close()
os.chdir(cwd)
def initialize():
global tts
tts = comtypes.client.CreateObject('sapi.SPVoice')
tts.Speak("",constants.SVSFIsXML)
def create_desktop_shortcut(app_name, title=None, parameters = ""):
title2 = title
parameters2 = parameters
if parameters2 == "":
parameters2 = app_name
if platform.system() == "Windows":
from comtypes.client import CreateObject
from comtypes.gen import IWshRuntimeLibrary
ws = CreateObject("WScript.Shell")
fname = os.path.join(get_desktop_folder(), app_name+".lnk")
icon_name = os.path.join(get_pytigon_path(), 'pytigon.ico')
scut = ws.CreateShortcut(fname).QueryInterface(IWshRuntimeLibrary.IWshShortcut)
scut.Description = title2
scut.TargetPath = os.path.join(get_pytigon_path(), "python\pythonw.exe")
scut.Arguments = os.path.join(get_pytigon_path(), "pytigon.py") + " " + parameters2
scut.IconLocation = icon_name
scut.Save()
else:
fname = os.path.join(get_desktop_folder(), app_name+".desktop")
if not os.path.exists(fname):
pytigon_path = get_pytigon_path()
desktop_str2 = DESKTOP_STR % (title2, pytigon_path, pytigon_path, parameters2, pytigon_path)
with open(fname,"wt") as f:
f.write(desktop_str2)