Check for presence of lockfile value before proceeding with context manager
This commit is contained in:
parent
4523d0c79d
commit
2d050eaaf9
@ -71,14 +71,16 @@ class PackageManager:
|
|||||||
:rtype: ``PackageManager`` object
|
:rtype: ``PackageManager`` object
|
||||||
:raises FileExistsError: if lockfile exists when this method is called
|
:raises FileExistsError: if lockfile exists when this method is called
|
||||||
"""
|
"""
|
||||||
self._lockfile.touch(mode=0o000)
|
if self._lockfile:
|
||||||
|
self._lockfile.touch(mode=0o000, exist_ok=False)
|
||||||
yield self
|
yield self
|
||||||
|
|
||||||
def __exit__(self):
|
def __exit__(self):
|
||||||
"""Remove the package manager's lockfile. After this lockfile is closed,
|
"""Remove the package manager's lockfile. After this lockfile is closed,
|
||||||
the package manager this class abstracts can perform transactions once again.
|
the package manager this class abstracts can perform transactions once again.
|
||||||
"""
|
"""
|
||||||
self._lockfile.unlink()
|
if self._lockfile:
|
||||||
|
self._lockfile.unlink()
|
||||||
|
|
||||||
def gen_pkglist(self):
|
def gen_pkglist(self):
|
||||||
"""Generate a text file listing installed packages
|
"""Generate a text file listing installed packages
|
||||||
|
Loading…
x
Reference in New Issue
Block a user