Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@Driver.check_active
@step(args=['filename'])
def load(self, filename=None):
if self.target.env:
usb_loader = self.target.env.config.get_image_path(self.usb_loader)
mf = ManagedFile(usb_loader, self.loader)
mf.sync_to_resource()
timeout = Timeout(3.0)
while True:
try:
processwrapper.check_output(
self.loader.command_prefix +
[self.tool, 'db', mf.get_remote_path()]
)
break
except subprocess.CalledProcessError:
@Driver.check_active
def get_status(self):
pass
@Driver.check_active
@step(args=['filename', 'remotepath'])
def put(self, filename, remotepath=''):
transfer_cmd = [
"scp",
*self.ssh_prefix,
"-P", str(self.networkservice.port),
filename,
"{user}@{host}:{remotepath}".format(
user=self.networkservice.username,
host=self.networkservice.address,
remotepath=remotepath)
]
try:
sub = subprocess.call(
transfer_cmd
@Driver.check_active
@step(title='call', args=['args'])
def __call__(self, *args):
arg_list = list(args)
arg_list.append('-p')
arg_list.append('{}'.format(self.flashrom_resource.programmer))
self.logger.debug('Call: %s with args: %s', self.tool, arg_list)
processwrapper.check_output(self._get_flashrom_prefix() + arg_list)
@Driver.check_active
def capture(self, filename, samplerate="200k"):
self._filename = filename
self._basename = os.path.basename(self._filename)
self.log.debug(
"Saving to: %s with basename: %s", self._filename, self._basename
)
cmd = [
"-l", "4", "--config", "samplerate={}".format(samplerate),
"--continuous", "-o"
]
filename = os.path.join(self._tmpdir, self._basename)
cmd.append(filename)
self._call_with_driver(*cmd)
args = self.sigrok.command_prefix + ['test', '-e', filename]
while subprocess.call(args):
@Driver.check_active
def get_session(self):
return self._xm.session
@Driver.check_active
@step(result=True)
def get_size(self):
args = ["cat", "/sys/class/block/{}/size".format(self.storage.path[5:])]
size = processwrapper.check_output(self.storage.command_prefix + args)
return int(size)
@Driver.check_active
@step(args=['interface'])
def get_ip(self, interface="eth0"):
"""Returns the IP of the supplied interface"""
try:
ip_string = self.command.run_check("ip -o -4 addr show")
except ExecutionError:
self.logger.debug('No ip address found')
return None
regex = re.compile(
r"""\d+: # Match the leading number
\s+(?P\w+) # Match whitespace and interfacename
\s+inet\s+(?P[\d.]+) # Match IP Adress
/(?P\d+) # Match prefix
.*global # Match global scope, not host scope""", re.X
)