This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/23210 )
Change subject: pySim-shell: add filesystem exporter
......................................................................
pySim-shell: add filesystem exporter
add a new command "export" that can either export indidividual files or
a whole directory tree. The command will generate a script that contains
update_binary and update_record commands along with the file contents.
This script can later be used to restore multiple files at once.
Change-Id: I82f3ce92cd91a5ed3c4884d62f6b22e9589c8a49
Related: OS#4963
---
M pySim-shell.py
1 file changed, 38 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/10/23210/1
diff --git a/pySim-shell.py b/pySim-shell.py
index 4544220..957b1a5 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -148,6 +148,44 @@
"""Display a filesystem-tree with all selectable files"""
self.walk()
+ def export(self, filename):
+ path_list_fid = self._cmd.rs.selected_file.fully_qualified_path(True)
+ path_list = self._cmd.rs.selected_file.fully_qualified_path(False)
+ self._cmd.poutput("# directory:%s (%s)" % ('/'.join(path_list_fid), '/'.join(path_list)))
+ try:
+ fcp_dec = self._cmd.rs.select(filename, self._cmd)
+ path_list_fid = self._cmd.rs.selected_file.fully_qualified_path(True)
+ path_list = self._cmd.rs.selected_file.fully_qualified_path(False)
+ self._cmd.poutput("# file:%s (%s)" % (path_list_fid[-1], path_list[-1]))
+
+ fd = fcp_dec['file_descriptor']
+ structure = fd['structure']
+ self._cmd.poutput("# structure: %s" % str(structure))
+
+ if structure == 'transparent':
+ result = self._cmd.rs.read_binary()
+ print ("update_binary " + str(result[0]))
+ if structure == 'cyclic' or structure == 'linear_fixed':
+ num_of_rec = fd['num_of_rec']
+ for r in range(1, num_of_rec + 1):
+ result = self._cmd.rs.read_record(r)
+ print ("update_record %d %s" % (r, str(result[0])))
+ fcp_dec = self._cmd.rs.select("..", self._cmd)
+ except Exception as e:
+ self._cmd.poutput("# bad file:%s, %s" % (str(filename), str(e)))
+
+ self._cmd.poutput("")
+
+ export_parser = argparse.ArgumentParser()
+ export_parser.add_argument('--filename', type=str, default=None, help='only export specific file')
+
+ @cmd2.with_argparser(export_parser)
+ def do_export(self, opts):
+ """Export files to script that can be imported back later"""
+ if opts.filename:
+ self.export(opts.filename)
+ else:
+ self.walk(0, self.export)
@with_default_category('USIM Commands')
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/23210
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I82f3ce92cd91a5ed3c4884d62f6b22e9589c8a49
Gerrit-Change-Number: 23210
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210303/a4745f67/attachment.htm>