Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions dex
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ class Application(DesktopEntry):

return cmd

def execute(self, action=None, term=None, wait=False, dryrun=False, verbose=False):
def execute(self, action=None, term=None, dryrun=False, verbose=False):
"""
Execute application or, if given, a specific action
@return Return subprocess.Popen object
Expand Down Expand Up @@ -561,8 +561,6 @@ class Application(DesktopEntry):
return

_execute_fn = subprocess.Popen
if wait:
_execute_fn = subprocess.run
if path:
return _execute_fn(cmd, cwd=path, env=os.environ)
return _execute_fn(cmd, env=os.environ)
Expand Down Expand Up @@ -738,15 +736,21 @@ def _autostart(args):
print("Dry run, nothing is executed.", file=sys.stderr)

exit_value = 0
subprocesses = []
for app in get_autostart_files(args, verbose=args.verbose):
try:
app.execute(term=args.term, dryrun=args.dryrun, verbose=args.verbose)
proc = app.execute(term=args.term, dryrun=args.dryrun, verbose=args.verbose)
subprocesses.append(proc)
except Exception as ex:
exit_value = 1
print(
"Execution failed: %s%s%s" % (app.filename, os.linesep, ex),
file=sys.stderr,
)
if args.wait:
for proc in subprocesses:
if proc:
proc.wait()
return exit_value


Expand All @@ -766,13 +770,14 @@ def _run(args):
for f in args.files:
try:
app = Application(f)
app.execute(
proc = app.execute(
action=args.action,
term=args.term,
wait=args.wait,
dryrun=args.dryrun,
verbose=args.verbose,
)
if args.wait and proc:
proc.wait()
except ValueError as ex:
print(ex, file=sys.stderr)
except IOError as ex:
Expand Down