cup.shell package

description:

shell related module

Submodules

cup.shell.expect module

description:

made a wraper out of paramiko.** The original copyright belongs to the author of paramiko module. See it at http://docs.paramiko.org/en/stable/

cup.shell.expect.checkssh(hostname, username, passwd)[source]

check if we can ssh to hostname. :return:a dict with keys (‘exitstatus’, ‘result’) exitstatus 0 success -1 others

cup.shell.expect.dscp(hostname, username, passwd, src, dst, timeout=9000)[source]

copy [hostname]:[src] to [localhost]:[dst].

Returns:

a dict with keys (‘exitstatus’, ‘result’) exitstatus 0 success -1 others

cup.shell.expect.go_ex(hostname, username, passwd, command='', timeout=600, b_print_stdout=True)[source]

execute command at remote. :return:a dict with keys (‘exitstatus’, ‘result’) exitstatus 0 success -1 others

cup.shell.expect.go_with_scp(hostname, username, passwd, command='', host_tmp='/tmp/', remote_tmp='/tmp/', timeout=800)[source]

Recommand using this function to remotely execute cmds.

go_witch_scp will write a temp script file and scp to hostname:[host_tmp]. Then execute it and get the result back.

Parameters:
  • host_tmp – temp folder for keeping the temporary script file (contains the cmd)

  • remote_tmp – remote temp folder for keeping the temporary script file

  • timeout – timeout

Returns:

a dict with keys (‘exitstatus’, ‘result’)

cup.shell.expect.lscp(src, hostname, username, passwd, dst, timeout=800)[source]

copy [localhost]:src to [hostname]:[dst]

:return:a dict with keys (‘exitstatus’, ‘result’) exitstatus 0 success -1 others

cup.shell.oper module

description:

shell operations related module

cup.shell.oper.backup_file(srcpath, filename, dstpath, label=None)[source]

Backup srcpath/filename to dstpath/filenamne.label. If label is None, cup will use time.strftime(‘%H:%M:S’)

Dstpath:

will create the folder if no existence

cup.shell.oper.contains_file(dstpath, expected_name, recursive=False, follow_link=False)[source]

judge if the dstfile is in dstpath

Parameters:
  • dstpath – search path

  • dstfile – file

  • recursive – search recursively or not. False by default.

Returns:

return True on success, False otherwise