2 @copyright: (C) 2008, Thomas Leonard
3 @see: U{http://roscidus.com}
7 from logging
import debug
9 from zeroinstall
.support
import tasks
# tmp
11 def wait_for_blocker(blocker
):
12 """Run a recursive mainloop until blocker is triggered.
13 @param blocker: event to wait on
14 @type blocker: L{tasks.Blocker}"""
15 if not blocker
.happened
:
16 loop
= gobject
.MainLoop(gobject
.main_context_default())
20 quit
= tasks
.Task(quitter(), "quitter")
22 debug("Entering mainloop, waiting for %s", blocker
)
25 assert blocker
.happened
, "Someone quit the main loop!"
29 def find_in_path(cmd
):
30 if os
.path
.isabs(cmd
):
32 for x
in os
.environ
['PATH'].split(':'):
33 full
= os
.path
.join(x
, cmd
)
34 if os
.path
.exists(full
):
38 def split_expanded_path(value
):
39 """Like os.path.split(os.path.expanduser(value))"""
40 if value
.startswith('~'):
41 value
= os
.path
.expanduser(value
)
42 if value
.startswith('~') and '/' not in value
:
43 value
= os
.path
.join(os
.path
.dirname(os
.path
.expanduser('~')), value
[1:])
44 return os
.path
.split(value
)