public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Brian Dolbec" <brian.dolbec@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/catalyst:pending commit in: catalyst/
Date: Sat, 14 Jun 2014 05:58:10 +0000 (UTC)	[thread overview]
Message-ID: <1402720540.5204bbcb0fb52892c4cc569cb404bab46949d32f.dol-sen@gentoo> (raw)

commit:     5204bbcb0fb52892c4cc569cb404bab46949d32f
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 20 01:50:26 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jun 14 04:35:40 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=5204bbcb

Move LockInUse from support.py to lock.py, fix bad execption raising,  pyflakes cleanup

---
 catalyst/lock.py    | 49 +++++++++++++++++++++++++++++++------------------
 catalyst/main.py    |  3 ++-
 catalyst/support.py | 11 -----------
 3 files changed, 33 insertions(+), 30 deletions(-)

diff --git a/catalyst/lock.py b/catalyst/lock.py
index 2d10d2f..ef00b49 100644
--- a/catalyst/lock.py
+++ b/catalyst/lock.py
@@ -3,14 +3,26 @@ import os
 import fcntl
 import errno
 import sys
-import string
 import time
-from catalyst.support import *
+from catalyst.support import CatalystError
 
 def writemsg(mystr):
 	sys.stderr.write(mystr)
 	sys.stderr.flush()
 
+
+class LockInUse(Exception):
+	def __init__(self, message):
+		if message:
+			#(type,value)=sys.exc_info()[:2]
+			#if value!=None:
+			    #print
+			    #kprint traceback.print_exc(file=sys.stdout)
+			print
+			print "!!! catalyst lock file in use: "+message
+			print
+
+
 class LockDir:
 	locking_method=fcntl.flock
 	lock_dirs_in_use=[]
@@ -109,7 +121,8 @@ class LockDir:
 	def fcntl_lock(self,locktype):
 		if self.myfd==None:
 			if not os.path.exists(os.path.dirname(self.lockdir)):
-				raise DirectoryNotFound, os.path.dirname(self.lockdir)
+				raise CatalystError("DirectoryNotFound: %s"
+					% os.path.dirname(self.lockdir))
 			if not os.path.exists(self.lockfile):
 				old_mask=os.umask(000)
 				self.myfd = os.open(self.lockfile, os.O_CREAT|os.O_RDWR,0660)
@@ -168,7 +181,7 @@ class LockDir:
 			print "lockfile does not exist '%s'" % self.lockfile
 			if (self.myfd != None):
 				try:
-					os.close(myfd)
+					os.close(self.myfd)
 					self.myfd=None
 				except:
 					pass
@@ -251,12 +264,13 @@ class LockDir:
 
 			self.add_hardlock_file_to_cleanup()
 			if not os.path.exists(self.myhardlock):
-				raise FileNotFound, "Created lockfile is missing: %(filename)s" % {"filename":self.myhardlock}
+				raise CatalystError("FileNotFound: Created lockfile is missing: "
+					"%(filename)s" % {"filename":self.myhardlock})
 			try:
-				res = os.link(self.myhardlock, self.lockfile)
-			except SystemExit, e:
+				os.link(self.myhardlock, self.lockfile)
+			except SystemExit:
 				raise
-			except Exception, e:
+			except Exception:
 #				if "DEBUG" in self.settings:
 #					print "lockfile(): Hardlink: Link failed."
 #					print "Exception: ",e
@@ -286,7 +300,7 @@ class LockDir:
 				os.unlink(self.myhardlock)
 			if os.path.exists(self.lockfile):
 				os.unlink(self.lockfile)
-		except SystemExit, e:
+		except SystemExit:
 			raise
 		except:
 			writemsg("Something strange happened to our hardlink locks.\n")
@@ -314,7 +328,7 @@ class LockDir:
 		try:
 			myhls = os.stat(link)
 			mylfs = os.stat(lock)
-		except SystemExit, e:
+		except SystemExit:
 			raise
 		except:
 			myhls = None
@@ -340,7 +354,7 @@ class LockDir:
 			pass
 
 	def hardlock_cleanup(self,path):
-		mypid  = str(os.getpid())
+		#mypid  = str(os.getpid())
 		myhost = os.uname()[1]
 		mydl = os.listdir(path)
 		results = []
@@ -384,26 +398,26 @@ class LockDir:
 								# We're sweeping through, unlinking everyone's locks.
 								os.unlink(filename)
 								results.append("Unlinked: " + filename)
-							except SystemExit, e:
+							except SystemExit:
 								raise
-							except Exception,e:
+							except Exception:
 								pass
 					try:
 						os.unlink(x)
 						results.append("Unlinked: " + x)
 						os.unlink(mylockname)
 						results.append("Unlinked: " + mylockname)
-					except SystemExit, e:
+					except SystemExit:
 						raise
-					except Exception,e:
+					except Exception:
 						pass
 				else:
 					try:
 						os.unlink(mylockname)
 						results.append("Unlinked: " + mylockname)
-					except SystemExit, e:
+					except SystemExit:
 						raise
-					except Exception,e:
+					except Exception:
 						pass
 		return results
 
@@ -423,7 +437,6 @@ if __name__ == "__main__":
 		return newpath
 
 	print "Lock 5 starting"
-	import time
 	Lock1=LockDir("/tmp/lock_path")
 	Lock1.write_lock()
 	print "Lock1 write lock"

diff --git a/catalyst/main.py b/catalyst/main.py
index 1ead9e8..30df771 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -21,7 +21,8 @@ sys.path.append(__selfpath__ + "/modules")
 from . import __version__
 import catalyst.config
 import catalyst.util
-from catalyst.support import CatalystError, find_binary, LockInUse
+from catalyst.lock import LockInUse
+from catalyst.support import CatalystError, find_binary
 from catalyst.defaults import (required_build_targets, valid_build_targets,
 	confdefaults)
 from hash_utils import HashMap, HASH_DEFINITIONS

diff --git a/catalyst/support.py b/catalyst/support.py
index d5dbfec..feaa645 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -115,17 +115,6 @@ class CatalystError(Exception):
 			print "!!! catalyst: "+message
 			print
 
-class LockInUse(Exception):
-	def __init__(self, message):
-		if message:
-			#(type,value)=sys.exc_info()[:2]
-			#if value!=None:
-			    #print
-			    #kprint traceback.print_exc(file=sys.stdout)
-			print
-			print "!!! catalyst lock file in use: "+message
-			print
-
 def die(msg=None):
 	warn(msg)
 	sys.exit(1)


             reply	other threads:[~2014-06-14  5:58 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-14  5:58 Brian Dolbec [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-11-22 15:52 [gentoo-commits] proj/catalyst:pending commit in: catalyst/ Brian Dolbec
2017-03-16 22:57 Brian Dolbec
2017-03-16 22:57 Brian Dolbec
2017-03-11  9:35 Brian Dolbec
2017-03-11  7:07 Brian Dolbec
2017-03-10 18:38 Brian Dolbec
2017-03-09 10:02 Brian Dolbec
2017-03-09  9:39 Brian Dolbec
2015-11-21  1:33 Brian Dolbec
2015-11-21  1:33 Brian Dolbec
2015-11-21  1:33 Brian Dolbec
2015-11-21  1:33 Brian Dolbec
2015-11-21  1:33 Brian Dolbec
2015-11-21  1:33 Brian Dolbec
2015-09-08 14:14 Brian Dolbec
2015-09-06 21:21 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-09-06 21:18 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-09-06 21:18 Brian Dolbec
2015-09-06 20:33 Brian Dolbec
2015-09-05 16:24 Brian Dolbec
2015-09-04 15:20 Brian Dolbec
2015-09-03 15:14 Brian Dolbec
2015-09-01  5:58 Brian Dolbec
2015-09-01  5:58 Brian Dolbec
2015-09-01  5:58 Brian Dolbec
2015-09-01  5:58 Brian Dolbec
2015-09-01  4:50 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-09-01  5:58 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-08-30 20:58 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-09-01  5:58 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-06-15 20:25 Brian Dolbec
2015-05-24  0:08 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-05-21 23:53 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-02-26 20:44 Brian Dolbec
2015-02-26 20:44 Brian Dolbec
2015-02-26 19:25 Brian Dolbec
2015-02-26  4:12 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-01-01  5:59 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-01-01  5:59 Brian Dolbec
2015-01-01  5:59 Brian Dolbec
2015-01-01  5:59 Brian Dolbec
2015-01-01  5:59 Brian Dolbec
2015-01-01  5:59 Brian Dolbec
2014-09-11  3:26 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2014-06-14  5:58 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2014-09-11  3:26 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2014-06-14  5:58 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2014-09-11  3:08 Brian Dolbec
2014-09-11  3:08 Brian Dolbec
2014-09-11  3:08 Brian Dolbec
2014-09-11  3:08 Brian Dolbec
2014-09-11  3:08 Brian Dolbec
2014-09-02 23:10 Brian Dolbec
2014-09-02 23:10 Brian Dolbec
2014-09-02 23:10 Brian Dolbec
2014-09-02 23:10 Brian Dolbec
2014-09-02 23:10 Brian Dolbec
2014-09-02  7:12 Brian Dolbec
2014-09-02  7:12 Brian Dolbec
2014-09-02  7:12 Brian Dolbec
2014-09-02  7:12 Brian Dolbec
2014-09-02  5:54 Brian Dolbec
2014-09-02  5:54 Brian Dolbec
2014-09-02  5:54 Brian Dolbec
2014-09-02  5:54 Brian Dolbec
2014-09-02  5:54 Brian Dolbec
2014-09-02  2:43 Brian Dolbec
2014-09-02  2:43 Brian Dolbec
2014-09-02  2:43 Brian Dolbec
2014-09-02  2:43 Brian Dolbec
2014-09-02  2:43 Brian Dolbec
2014-06-15 14:56 Brian Dolbec
2014-06-15 14:56 Brian Dolbec
2014-06-15 14:56 Brian Dolbec
2014-06-15 14:56 Brian Dolbec
2014-06-15 14:56 Brian Dolbec
2014-06-14  5:58 Brian Dolbec
2014-06-14  5:58 Brian Dolbec
2014-06-14  5:58 Brian Dolbec
2014-06-14  5:58 Brian Dolbec
2014-06-14  5:58 Brian Dolbec
2014-05-05 19:17 [gentoo-commits] proj/catalyst:master " Brian Dolbec
2014-04-02 20:09 ` [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2014-04-02 20:09 Brian Dolbec
2014-04-02 20:09 Brian Dolbec
2014-04-02 20:09 Brian Dolbec
2014-03-22 22:25 Brian Dolbec
2014-03-22 22:25 Brian Dolbec
2014-03-22 22:25 Brian Dolbec
2014-03-22 22:25 Brian Dolbec
2014-03-22 22:25 Brian Dolbec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1402720540.5204bbcb0fb52892c4cc569cb404bab46949d32f.dol-sen@gentoo \
    --to=brian.dolbec@gmail.com \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox