summaryrefslogtreecommitdiffstats
path: root/bin/lock-helper.py
blob: 5c332b2afd4d219b97644c0ba9417e0189225f7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/python
# Copyright 2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

import sys
import portage

def main(args):

	if args and sys.hexversion < 0x3000000 and not isinstance(args[0], unicode):
		for i, x in enumerate(args):
			args[i] = portage._unicode_decode(x, errors='strict')

	lock_obj = portage.locks.lockfile(args[0], wantnewlockfile=True)
	sys.stdout.write('\0')
	sys.stdout.flush()
	sys.stdin.read(1)
	portage.locks.unlockfile(lock_obj)
	return portage.os.EX_OK

if __name__ == "__main__":
	rval = main(sys.argv[1:])
	sys.exit(rval)