From 35347294212b9294ae8b0ba594264b888835e581 Mon Sep 17 00:00:00 2001 From: "kuldeep.k@cisinlabs.com" Date: Thu, 26 Aug 2021 21:00:05 +0530 Subject: [PATCH 1/4] Updated code quality removed print statement spaces in singleinstance.py --- src/singleinstance.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/singleinstance.py b/src/singleinstance.py index 09ca2e9a..188b2d1c 100644 --- a/src/singleinstance.py +++ b/src/singleinstance.py @@ -75,7 +75,7 @@ class singleinstance(object): fcntl.lockf(self.fp, fcntl.LOCK_EX | fcntl.LOCK_NB) self.lockPid = os.getpid() except IOError: - print ('Another instance of this application is already running') + print('Another instance of this application is already running') sys.exit(-1) else: pidLine = "%i\n" % self.lockPid @@ -99,7 +99,7 @@ class singleinstance(object): pass return - print ("Cleaning up lockfile") + print("Cleaning up lockfile") try: if sys.platform == 'win32': if hasattr(self, 'fd'): -- 2.45.1 From 1f122fba234cabf8bb8cf6ff3148c1e4af764e9d Mon Sep 17 00:00:00 2001 From: "kuldeep.k@cisinlabs.com" Date: Thu, 2 Sep 2021 16:42:47 +0530 Subject: [PATCH 2/4] Removed except block print statements & added specific message to sys.exit function --- src/singleinstance.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/singleinstance.py b/src/singleinstance.py index 188b2d1c..c1e20c4b 100644 --- a/src/singleinstance.py +++ b/src/singleinstance.py @@ -55,12 +55,7 @@ class singleinstance(object): ) except OSError as e: if e.errno == 13: - print( - 'Another instance of this application' - ' is already running' - ) - sys.exit(-1) - print(e.errno) + sys.exit('Another instance of this application is already running') raise else: pidLine = "%i\n" % self.lockPid @@ -75,8 +70,7 @@ class singleinstance(object): fcntl.lockf(self.fp, fcntl.LOCK_EX | fcntl.LOCK_NB) self.lockPid = os.getpid() except IOError: - print('Another instance of this application is already running') - sys.exit(-1) + sys.exit('Another instance of this application is already running') else: pidLine = "%i\n" % self.lockPid self.fp.truncate(0) -- 2.45.1 From 7d945a5c68b5175a342e5a0c1e72bbfbd8374819 Mon Sep 17 00:00:00 2001 From: "kuldeep.k@cisinlabs.com" Date: Mon, 6 Sep 2021 21:21:28 +0530 Subject: [PATCH 3/4] Fixed PEP8 warnings --- src/singleinstance.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/singleinstance.py b/src/singleinstance.py index c1e20c4b..19ffc7cc 100644 --- a/src/singleinstance.py +++ b/src/singleinstance.py @@ -55,7 +55,9 @@ class singleinstance(object): ) except OSError as e: if e.errno == 13: - sys.exit('Another instance of this application is already running') + sys.exit( + 'Another instance of this application is' + ' already running') raise else: pidLine = "%i\n" % self.lockPid @@ -70,7 +72,9 @@ class singleinstance(object): fcntl.lockf(self.fp, fcntl.LOCK_EX | fcntl.LOCK_NB) self.lockPid = os.getpid() except IOError: - sys.exit('Another instance of this application is already running') + sys.exit( + 'Another instance of this application is' + ' already running') else: pidLine = "%i\n" % self.lockPid self.fp.truncate(0) -- 2.45.1 From 579a3d21433ca708de5544ea091c743ac9e26eb1 Mon Sep 17 00:00:00 2001 From: "kuldeep.k@cisinlabs.com" Date: Tue, 7 Sep 2021 22:01:45 +0530 Subject: [PATCH 4/4] Removed print statement --- src/singleinstance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/singleinstance.py b/src/singleinstance.py index 19ffc7cc..660dcf54 100644 --- a/src/singleinstance.py +++ b/src/singleinstance.py @@ -97,7 +97,7 @@ class singleinstance(object): pass return - print("Cleaning up lockfile") + try: if sys.platform == 'win32': if hasattr(self, 'fd'): -- 2.45.1