Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@eel.expose
def sketch_refresh(guid, geometry):
proxy = proxies.get(guid)
if proxy:
proxy.io = mock.MockIO()
proxy.canvas = drawing.Canvas(*geometry)
try:
if proxy.refresh_callback != None:
proxy.refresh_callback()
else:
run_metacode(guid) # No refresh callback defined - re-run all code
except Exception as e:
import traceback
traceback.print_exc()
print('-'*50)
#pass;print('Exception sketch_refresh:', e)
@eel.expose
def getfiledata(filename):
print('* Generating Titles File Data')
if filename.endswith('.nsp') or filename.endswith('.nsx') or filename.endswith('.nsz'):
f = Fs.ChromeNsp(filename, 'rb')
elif filename.endswith('.xci') or filename.endswith('.xcz'):
f = Fs.ChromeXci(filename)
else: return ""
feed=f.adv_file_list()
f.flush()
f.close()
return feed
@eel.expose
def key_down(guid, key):
gui[key] = True
for callback in callbacks[key].values():
try:
callback(guid, key, True)
except:
...
@eel.expose
def api_get_sources():
ret = {'available': [], 'active': [], 'filters': {}}
for s in sources.load_sources():
ret['available'].append(s.to_obj(for_webui=True))
for s in settings.get_sources():
ret['active'].append(s.to_obj(for_webui=True))
ret['filters']['available'] = [f.to_js_obj() for f in filters.get_filters()]
ret['filters']['operators'] = [f.value for f in filters.Operators]
return ret
@eel.expose
def getcnmtdata(filename):
print('* Reading Data from Cnmt')
if filename.endswith('.nsp')or filename.endswith('.nsx') or filename.endswith('.nsz'):
f = Fs.ChromeNsp(filename, 'rb')
elif filename.endswith('.xci') or filename.endswith('.xcz'):
f = Fs.ChromeXci(filename)
else: return ""
feed=f.read_cnmt()
f.flush()
f.close()
return feed
@eel.expose
def pick_file(folder):
if os.path.isdir(folder):
return random.choice(os.listdir(folder))
else:
return 'Not valid folder'
@eel.expose
def run(code, stdin=''):
while state['mode'] != 'stopped':
state['mode'] = 'interrupt'
eel.sleep(0.01)
state['mode'] = 'running'
sta.execution_start()
exe.bounded_exec(code, 10**7, report)
state['mode'] = 'stopped'
@eel.expose
def check_if_file_exists(file):
""" Checks if a file exists """
return os.path.isfile(file)
@eel.expose
def update_mouse_position(x, y):
gui['mouse'] = (x, y)
@eel.expose
def get_all_variables():
var_names = [str(s) for s in rec.get_all_variables()] # weird bugs here...
return sorted(var_names)