You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 14, 2019. It is now read-only.
go=False#true when file has been successfully read
8
+
lines= [] #an array of strings which represent each line of the file
9
+
filename=raw_input("File name: ") #the name of the file to read (user input)
10
+
oneline=""#the file as a single string
11
+
retry=False#whether or not to retry.
12
+
13
+
ifnotNetworkTables.isConnected():
14
+
print("You aren't connected to the bot.")
15
+
quit()
16
+
#loops until a file is read into the file array
17
+
whilenotgo:
18
+
ifretry:
19
+
filename=raw_input("Not found. Try another name (enter to quit): ")#retry, or quit (in case the file doesn't exist)
20
+
iffilename=="":
21
+
quit()
22
+
try:
23
+
withopen(filename) asscript:
24
+
lines=script.readlines()
25
+
oneline="".join(lines) #this is python's weird syntax for joining an array into one line, as we can't seem to pull string arrays from the WPILib Preferences class.
26
+
break
27
+
except:
28
+
retry=True
29
+
#puts the string
30
+
prefs.putString("autoscripts", oneline)
31
+
print("Uploading %s as a String[] to key \"autoscripts\""%filename)
32
+
33
+
#checks if the key has been filled
34
+
tester=""#a variable to check if autoscripts is None
35
+
36
+
tester=prefs.getValue("autoscripts", None)
37
+
iftester!=oneline:
38
+
print("It doesn't look like key \"autoscripts\" is filled, maybe you aren't connected to networktables?")
0 commit comments