Skip to content

Commit

Permalink
Add 'fetch' command to drakplayground (#936)
Browse files Browse the repository at this point in the history
  • Loading branch information
psrok1 authored Jul 24, 2024
1 parent 6d9a773 commit b26bfbc
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions drakrun/drakrun/playground.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ def help(self):
usage = dedent(
"""\
Available commands:
- copy(file_path) # copy file onto vm desktop
- copy(file_path, <remote_path>) # copy file to guest (by default to vm desktop)
- fetch(remote_path, <local_path>) # fetch file from guest (by default into current directory)
- mount(iso_path) # mount iso, useful for installing software, e.g. office
- drakvuf(plugins) # start drakvuf with provided set of plugins
- run(cmd) # run command inside vm
Expand All @@ -130,9 +131,15 @@ def help(self):
)
print(usage)

def copy(self, local):
def copy(self, local, remote=None):
local = Path(local)
self.injector.write_file(local, self.desktop / local.name)
remote = WinPath(remote) if remote is not None else self.desktop / local.name
self.injector.write_file(local, remote)

def fetch(self, remote, local=None):
remote = WinPath(remote)
local = Path(local) if local is not None else Path(".") / remote.name
self.injector.read_file(remote, local)

def mount(self, local_iso_path, drive=FIRST_CDROM_DRIVE):
local_iso_path = Path(local_iso_path)
Expand Down Expand Up @@ -179,6 +186,7 @@ def main():
helpers = {
"help": shell.help,
"copy": shell.copy,
"fetch": shell.fetch,
"mount": shell.mount,
"drakvuf": shell.drakvuf,
"vm": shell.vm,
Expand Down

0 comments on commit b26bfbc

Please sign in to comment.