Change in pysim[master]: pySim-shell: add basic filesystem check

dexter gerrit-no-reply at lists.osmocom.org
Thu Mar 18 22:02:42 UTC 2021


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/23403 )


Change subject: pySim-shell: add basic filesystem check
......................................................................

pySim-shell: add basic filesystem check

Add a tool (similar to tree) that walks through the FS and selects each
file. If the file can not be selected, report an error.

Change-Id: I9248e2fc067f822d9c4ccc4e48d378eea9ce3354
Related: OS#4963
---
M pySim-shell.py
1 file changed, 22 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/03/23403/1

diff --git a/pySim-shell.py b/pySim-shell.py
index 8a0446e..80428c2 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -225,6 +225,28 @@
 		if context['ERR']:
 			raise RuntimeError("unable to export %i file(s)" % context['ERR'])
 
+	def check(self, filename, context):
+		context['COUNT'] += 1
+		path_list = self._cmd.rs.selected_file.fully_qualified_path(True)
+		output_str = "checking: %s" % ('/'.join(path_list)) + "/" + filename
+		output_str += " " * 45
+		output_str = output_str[0:45]
+		try:
+			fcp_dec = self._cmd.rs.select(filename, self._cmd)
+			fcp_dec = self._cmd.rs.select("..", self._cmd)
+			output_str += " ok"
+		except Exception as e:
+			output_str += " error: " + str(e)
+			context['ERR'] += 1
+		self._cmd.poutput(output_str)
+
+	def do_check(self, opts):
+		"""Check all files in the file system for availability"""
+		context = {'ERR':0, 'COUNT':0}
+		self.walk(0, self.check, context)
+		self._cmd.poutput("total files visited: %u" % context['COUNT'])
+		self._cmd.poutput("bad files:     %u" % context['ERR'])
+
 
 @with_default_category('USIM Commands')
 class UsimCommands(CommandSet):

-- 
To view, visit https://gerrit.osmocom.org/c/pysim/+/23403
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I9248e2fc067f822d9c4ccc4e48d378eea9ce3354
Gerrit-Change-Number: 23403
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210318/4e3b9f02/attachment.htm>


More information about the gerrit-log mailing list