Skip to content

Commit 870d055

Browse files
committed
some more bug fixes
1 parent aa09192 commit 870d055

File tree

1 file changed

+36
-52
lines changed

1 file changed

+36
-52
lines changed

src/romloader.py

Lines changed: 36 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -72,64 +72,48 @@ def main():
7272
except KeyError:
7373
path = '/romloader'
7474
romname = filename
75-
conn.MakeDir('/romloader')
7675

7776
print("getting list of {path} to verify path exists".format(
7877
path=path
7978
))
80-
try:
81-
# initiate connection to the websocket server
82-
conn = usb2snes()
83-
84-
# Attach to usb2snes, use the device configured if it is set, otherwise
85-
# have it find the first device.
86-
if "device" in config:
87-
print('Attaching to specified device {device}'.format(
88-
device=config['device']
79+
for a in range(3):
80+
try:
81+
# initiate connection to the websocket server
82+
conn = usb2snes()
83+
84+
# Attach to usb2snes, use the device configured if it is set, otherwise
85+
# have it find the first device.
86+
if "device" in config:
87+
print('Attaching to specified device {device}'.format(
88+
device=config['device']
89+
))
90+
com = conn.Attach(config['device'])
91+
else:
92+
print('Attaching to first device found.')
93+
com = conn.Attach()
94+
print('Attached to device \"{com}\"'.format(
95+
com=com
8996
))
90-
com = conn.Attach(config['device'])
91-
else:
92-
print('Attaching to first device found.')
93-
com = conn.Attach()
94-
print('Attached to device \"{com}\"'.format(
95-
com=com
96-
))
97-
98-
conn.Name('RomLoader')
99-
conn.List(path)
100-
except:
101-
conn.close()
102-
sleep(1)
103-
# initiate connection to the websocket server
104-
conn = usb2snes()
105-
106-
# Attach to usb2snes, use the device configured if it is set, otherwise
107-
# have it find the first device.
108-
if "device" in config:
109-
print('Attaching to specified device {device}'.format(
110-
device=config['device']
97+
98+
conn.Name('RomLoader')
99+
if not rule:
100+
conn.MakeDir('/romloader')
101+
conn.List(path)
102+
print("copying rom to {fullpath}".format(
103+
fullpath=path + '/' + romname
111104
))
112-
com = conn.Attach(config['device'])
113-
else:
114-
print('Attaching to first device found.')
115-
com = conn.Attach()
116-
print('Attached to device \"{com}\"'.format(
117-
com=com
118-
))
119-
120-
conn.Name('RomLoader')
121-
conn.List(path)
122-
print("copying rom to {fullpath}".format(
123-
fullpath=path + '/' + romname
124-
))
125-
conn.PutFile(rompath, path + '/' + romname)
126-
print("verifying rom copy is complete")
127-
conn.List(path)
128-
print("booting rom")
129-
conn.Boot(path + '/' + romname)
130-
conn.close()
131-
132-
sleep(5)
105+
conn.PutFile(rompath, path + '/' + romname)
106+
print("verifying rom copy is complete")
107+
conn.List(path)
108+
print("booting rom")
109+
conn.Boot(path + '/' + romname)
110+
conn.close()
111+
112+
sleep(5)
113+
break
114+
except:
115+
conn.close()
116+
continue
133117

134118

135119
def matchrule(name):

0 commit comments

Comments
 (0)