From 4c177e6eb71ab2b068f6426b9d141be47fc1f667 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Wed, 12 Sep 2018 22:17:45 +0200 Subject: Python2 -> Python3 --- cmount.py | 13 +++++-------- cumount.py | 13 +++++-------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/cmount.py b/cmount.py index e2dc8bf..2a7f201 100755 --- a/cmount.py +++ b/cmount.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- import json @@ -9,8 +9,7 @@ import time def main(): - """ - """ + if (len(sys.argv) != 2): sys.exit('Invalid parameter. Usage: {0} \n'.format( sys.argv[0])) @@ -63,11 +62,9 @@ def main(): arguments.append(data['target']) subprocess.check_call(arguments) except subprocess.CalledProcessError as e: - sys.stderr.write('Execution error: {0}\n'.format(e)) - sys.stderr.flush() - except Exception as e: - sys.stderr.write('Error: {0}\n'.format(cstm_error)) - sys.stderr.flush() + print('Execution error: {0}\n'.format(e), file=sys.stderr, flush=True) + except Exception: + print('Error: {0}\n'.format(cstm_error), file=sys.stderr, flush=True) if __name__ == '__main__': diff --git a/cumount.py b/cumount.py index 565c3fb..0813397 100755 --- a/cumount.py +++ b/cumount.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- import json @@ -8,8 +8,7 @@ import sys def main(): - """ - """ + if (len(sys.argv) != 2): sys.exit('Invalid parameter. Usage: {0} \n'.format( sys.argv[0])) @@ -56,11 +55,9 @@ def main(): '-d', loop_device]) except subprocess.CalledProcessError as e: - sys.stderr.write('Execution error: {0}\n'.format(e)) - sys.stderr.flush() - except Exception as e: - sys.stderr.write('Error: {0}\n'.format(cstm_error)) - sys.stderr.flush() + print('Execution error: {0}\n'.format(e), file=sys.stderr, flush=True) + except Exception: + print('Error: {0}\n'.format(cstm_error), file=sys.stderr, flush=True) if __name__ == '__main__': -- cgit v1.3