MCPcopy
hub / github.com/RUB-NDS/PRET / do_open

Method do_open

printer.py:204–230  ·  view source on GitHub ↗

Connect to remote device: open

(self, arg, mode="")

Source from the content-addressed store, hash-verified

202
203 # ------------------------[ open <target> ]---------------------------
204 def do_open(self, arg, mode=""):
205 "Connect to remote device: open <target>"
206 if not arg:
207 arg = eval(input("Target: "))
208 # open connection
209 try:
210 newtarget = arg != self.target
211 self.target = arg # set new target
212 self.conn = conn(self.mode, self.debug, self.quiet)
213 self.conn.timeout(self.timeout)
214 self.conn.open(arg)
215 print(("Connection to " + arg + " established"))
216 # hook method executed after successful connection
217 self.on_connect(mode)
218 # show some information about the device
219 if not self.quiet and mode != "reconnect":
220 sys.stdout.write("Device: ")
221 self.do_id()
222 print("")
223 # set printer default values
224 self.set_defaults(newtarget)
225 except Exception as e:
226 output().errmsg("Connection to " + arg + " failed", e)
227 self.do_close()
228 # exit if run from init function (command line)
229 if mode == "init":
230 self.do_exit()
231
232 # wrapper to send data
233 def send(self, data):

Callers 3

__init__Method · 0.95
do_reconnectMethod · 0.95
reconnectMethod · 0.95

Calls 11

on_connectMethod · 0.95
do_idMethod · 0.95
set_defaultsMethod · 0.95
do_closeMethod · 0.95
do_exitMethod · 0.95
connClass · 0.90
outputClass · 0.90
timeoutMethod · 0.80
errmsgMethod · 0.80
openMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected