@@ -50,25 +50,6 @@ def main():
5050 sys .exit (1 )
5151 filename = os .path .basename (rompath )
5252
53- # initiate connection to the websocket server
54- conn = usb2snes ()
55-
56- # Attach to usb2snes, use the device configured if it is set, otherwise
57- # have it find the first device.
58- if "device" in config :
59- print ('Attaching to specified device {device}' .format (
60- device = config ['device' ]
61- ))
62- com = conn .Attach (config ['device' ])
63- else :
64- print ('Attaching to first device found.' )
65- com = conn .Attach ()
66- print ('Attached to device \" {com}\" ' .format (
67- com = com
68- ))
69-
70- conn .Name ('RomLoader' )
71-
7253 rule = matchrule (filename )
7354 if rule :
7455 if len (config ['rules' ][rule ]['destinations' ]) == 1 :
@@ -97,8 +78,46 @@ def main():
9778 path = path
9879 ))
9980 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
96+ ))
97+
98+ conn .Name ('RomLoader' )
10099 conn .List (path )
101100 except :
101+ conn .close ()
102+ sleep (5 )
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' ]
111+ ))
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' )
102121 conn .List (path )
103122 print ("copying rom to {fullpath}" .format (
104123 fullpath = path + '/' + romname
0 commit comments