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

Method do_put

printer.py:472–491  ·  view source on GitHub ↗

Send file: put

(self, arg, rpath="")

Source from the content-addressed store, hash-verified

470
471 # ------------------------[ put <local file> ]------------------------
472 def do_put(self, arg, rpath=""):
473 "Send file: put <local file>"
474 if not arg:
475 arg = eval(input("Local file: "))
476 if not rpath:
477 rpath = os.path.basename(arg)
478 rpath = self.rpath(rpath)
479 lpath = os.path.abspath(arg)
480 # read from local file
481 data = file().read(lpath)
482 if data != None:
483 self.put(rpath, data)
484 lsize = len(data)
485 rsize = self.file_exists(rpath)
486 if rsize == lsize:
487 print((str(rsize) + " bytes transferred."))
488 elif rsize == c.NONEXISTENT:
489 print("Permission denied.")
490 else:
491 self.size_mismatch(lsize, rsize)
492
493 # ------------------------[ append <file> <string> ]------------------
494 def do_append(self, arg):

Callers 1

do_editMethod · 0.95

Calls 7

rpathMethod · 0.95
size_mismatchMethod · 0.95
fileClass · 0.90
basenameMethod · 0.80
readMethod · 0.80
putMethod · 0.45
file_existsMethod · 0.45

Tested by

no test coverage detected