Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
event.add('dtstamp', datetime.replace( datetime.now(), tzinfo=LocalTimezone() ))
event['uid'] = str(randint(1,10**30)) + datetime.now().strftime('%Y%m%dT%H%M%S') + '___n8henrie.com'
cal.add_component(event)
rownum += 1
except Exception, e:
if rownum > 0:
easygui.msgbox('I had a problem with an event. I think I might have gotten through about {0} events and had trouble with an event with subject: {1}. Sorry!'.format(rownum, row['Subject']))
logger.exception(e)
elif rownum == 0:
easygui.msgbox('Looks like I didn\'t even get through the first event. Sorry!')
logger.exception(e)
else:
easygui.msgbox('Somehow it looks like I processed negative events... that shouldn\'t have happened. Sorry!')
logger.exception(e)
sys.exit(2)
try:
# Write final .ics file to same directory as input file.
if isdir(expanduser('~/Desktop')):
f = open(easygui.filesavebox(msg='Save .ics File', title='', default=expanduser('~/Desktop/') + 'calendar.ics', filetypes=['*.ics']), 'wb')
else:
f = open(easygui.filesavebox(msg='Save .ics File', title='', default=expanduser('~/') + 'calendar.ics', filetypes=['*.ics']), 'wb')
# For testing comment 4 lines above (2 x if / else) and use this:
# f = open('path_to_tester.csvcalendar.ics', 'wb')
f.write(cal.to_ical())
f.close()
def errorPrompt(errorMsg):
print 'Error: ' + errorMsg
easygui.msgbox(msg = errorMsg, title = 'ERROR', ok_button = 'OK')
quit()
try:
if infile == None:
start_dir = '~/'
if isdir(expanduser("~/Desktop")):
start_dir = '~/Desktop/'
msg = 'Please select the .csv file to be converted to .ics'
infile = easygui.fileopenbox(msg=msg, title="", default=expanduser(start_dir), filetypes=["*.csv"])
reader_builder = list(csv.DictReader(open(infile, 'U'), skipinitialspace = True))
# For testing comment 4 lines above (2 x if / else) and use this:
# reader_builder = list(csv.DictReader(open('path_to_tester.csv', 'rb'), skipinitialspace = True))
except Exception as e:
logger.exception(e)
easygui.msgbox("Looks like there was an error opening the file, didn't even make it to the conversion part. Sorry!")
sys.exit(1)
# Filter out events with empty subjects, a required element
# for a calendar event.
# Code found here: http://bit.ly/Z4Pg4h
reader_builder[:] = [d for d in reader_builder if d.get('Subject') != '']
headers = reader_builder[0].keys()
logger.debug('reader_builder[0].keys(): {}'.format(headers))
check_headers(headers)
reader = clean_spaces(reader_builder)
# Start calendar file
cal = Calendar()
cal.add('prodid', 'n8henrie.com')
eg.msgbox("Press the reset button on the stimulator, then click OK")
print("Waiting for the stimulator to come back online...")
time.sleep(10)
postsession=[]
for item in protosplit[1].split("\n"):
if "/2" in item or "/3" in item and "NPHYS" not in item:
postsession.append(item[:item.find("/")])
print(str(postsession))
if len(postsession) > 0:
hasData=True
postsession.append("Comments")
postData=eg.multenterbox("This protocol requires values for the following post-session metrics","Outcome measures",postsession)
if "NPHYS/2" in protosplit[1] or "NPHYS/3" in protosplit[1]:
hasdata=True
eg.msgbox("This protocol calls for neurophysiological data collection. Click OK to begin data collection.")
connectStim()
postname=fileName+"-postsession-"+str(randint(0,9999))
recordData(postname)
#now string things together to make the log file
header=""
data=""
if len(prename) >0:
header=header+"prestim-nphys-file\t"
data=data+prename+"\t"
if len(postname) > 0:
header=header+"poststim-nphys-file\t"
data=data+postname+"\t"
header=header+"sham\t"
if sham:
data=data+"1\t"
else:
else:
if easygui.ynbox("Would you like to exit?"):
sys.exit()
else:
getdata(inputtype, easyguiargs)
plugname = getdata("enterbox", "What would you like to name the plugin?")
# Add more choices here if the plugin module gets increased variability
typechoices = ["Python", "Terminal Command"]
plugtype = getdata("buttonbox", ("Please pick a plugintype", typechoices))
if plugtype == typechoices[0]:
formalplugtype = 'python'
elif plugtype == typechoices[1]:
formalplugtype = 'exec'
else:
easygui.msgbox("Unrecognized plugin type {0}".format(plugtype))
sys.exit()
required = []
possiblerequired = ["command", "name", "email", "phone", "time", "date"]
for item in possiblerequired:
if getdata('ynbox', 'Does your plugin require {0} to be passed to it?'.format(item)):
required.append(item)
else:
pass
syns = []
synsraw = getdata("enterbox",
"Please enter all synonym words or phrases for your plugin, seperated with commas. No spaces in between synonyms. If there are no synonyms, just hit OK.")
if ',' in synsraw:
for item in synsraw.split(','):
syns.append(item)
else:
if synsraw != '':
import dbquery
OPENINGMSG = "What would you like to look up?"
TITLE = "DB Query Application"
CHOICES = ["Department", "IP", "Hostname", "Device Type"]
CHOICE = g.choicebox(OPENINGMSG, TITLE, CHOICES)
if CHOICE == "Department":
department = g.enterbox("What is the dept you want to search for?", TITLE)
RDept = dbquery.querydept(department)
g.msgbox(RDept, TITLE)
elif CHOICE == "IP":
ip = g.enterbox("What is the ip you want to search for?", TITLE)
RIP = dbquery.queryip(ip)
g.msgbox(RIP, TITLE)
elif CHOICE == "Hostname":
hostname = g.enterbox("What is the hostname you want to search for?", TITLE)
RHost = dbquery.queryip(hostname)
g.msgbox(RHost, TITLE)
elif CHOICE == "Device Type":
device_type = g.enterbox("What is the device type you want to search for?", TITLE)
RdType = dbquery.queryip(device_type)
g.msgbox(RdType, TITLE)
def _get_run_id(self):
msg = '''
Please choose one of the following methods for defining gene families.
OrthoMCL runs are useful for identifying orthologs (genes likely to share a function)
maxbit runs are useful for identifying broader
gene families. c_xxx in the following list means xxx was used as a cutoff. Higher
cutoffs mean more stringent similarity to define a family of related genes.
Note that only the groups of organisms that contain your gene are listed here.
'''
valid_choices = self.accumulated_data['run_to_cluster'].keys()
if len(valid_choices) == 0:
easygui.msgbox('The chosen gene is not found in any clustering results!')
return True
runid = easygui.choicebox(msg, 'Select a cluster run', valid_choices)
# Canceling from here - just go back to the other menu
if runid is None:
return runid
self.accumulated_data['runid'] = runid
return runid
# Analyses on a single gene.
print "start4"
#print "startPose", startPose
#print "targetToWorld", targetToWorld
#print "graspingHand", self.graspingHand
constraintSet = self.ikPlanner.planEndEffectorGoal(startPose, self.graspingHand, targetToWorld, lockBase=False, lockBack=True)
with Timer('start5'):
print "start5"
endPose, info = constraintSet.runIk()
print info
with Timer('start6'):
print "start6"
graspPlan = constraintSet.runIkTraj()
easygui.msgbox("Please review the plan", title="Pause")
if not easygui.ynbox("Do next iteration?", title=" "):
break
# print "start7"
# if graspPlan.plan_info[-1] > 10:
# print "PLANNER REPORTS ERROR!"
#
# self.planPlaybackFunction([graspPlan])
#
# #self.fail()
# break
# else:
# print "Planner reports success!"
#
# # Plan was successful, save it to be animated and update output data
# self.planPlaybackFunction([graspPlan])
thisData=theData[command]
if (thisData == 0):
regFail=True
print("CAUTION:The stimulator may have reset due to an electrical fault")
values.append(float(thisData))
except Exception: #some sort of decode failure
1+1
maxData=abs(averageArray(values))
if (maxData >= 0.9 and maxData < 1.1):
print("Backward current test passed")
else:
print("***Backward current test failed! Mean current was "+str(maxData))
regFail=True
headset.closeConnection()
if regFail:
eg.msgbox("The regulator failed to generate the correct current on at least one electrode. Review the log to see details")
else:
eg.msgbox("Test complete. No issues detected.")
if "Short" in testSelect:
eg.msgbox("Disconnect the headset from your body, then click OK to continue.",title="Short/bridge test")
gocommand=[9,19,29,39,49,59]
gregFail=False
if connectStim():
for command in range(0,len(gocommand)):
headset.startStim(2000)
headset.startStim(610)
headset.startStim(800)
print("Testing electrode "+electrodeNames[command])
headset.flushData()
regFail=False
for ncommand in [4, 14, 24, 34, 44, 54]: