Enable BytesWarnings.
[portage.git] / bin / lock-helper.py
1 #!/usr/bin/python -bb
2 # Copyright 2010-2014 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 import os
6 import sys
7 sys.path.insert(0, os.environ['PORTAGE_PYM_PATH'])
8 import portage
9 portage._internal_caller = True
10 portage._disable_legacy_globals()
11
12 def main(args):
13
14         if args and isinstance(args[0], bytes):
15                 for i, x in enumerate(args):
16                         args[i] = portage._unicode_decode(x, errors='strict')
17
18         # Make locks quiet since unintended locking messages displayed on
19         # stdout would corrupt the intended output of this program.
20         portage.locks._quiet = True
21         lock_obj = portage.locks.lockfile(args[0], wantnewlockfile=True)
22         sys.stdout.write('\0')
23         sys.stdout.flush()
24         sys.stdin.read(1)
25         portage.locks.unlockfile(lock_obj)
26         return portage.os.EX_OK
27
28 if __name__ == "__main__":
29         rval = main(sys.argv[1:])
30         sys.exit(rval)