I'm getting this error:
Traceback (most recent call last): File "app.py", line 29, in print(get_active_window_title()) File "app.py", line 7, in get_active_window_title output = subprocess.check_output('./app.sh') File "/home/rishabh/anaconda2/lib/python2.7/subprocess.py", line 216, in check_output process = Popen(stdout=PIPE, *popenargs, **kwargs) File "/home/rishabh/anaconda2/lib/python2.7/subprocess.py", line 394, in init errread, errwrite) File "/home/rishabh/anaconda2/lib/python2.7/subprocess.py", line 1047, in _execute_child raise child_exception OSError: [Errno 13] Permission denied when running project code
when I'm trying to run this code on a fresh ubuntu install, which used to work perfectly before. chmod doesn't work. Following is the code
import sys
import os
import subprocess
import re
import cv2
def get_active_window_title():
output = subprocess.check_output('./app.sh')
if output.decode("utf-8") == "Desktop\n":
return "Desktop"
else:
root = subprocess.Popen(['xprop', '-root', '_NET_ACTIVE_WINDOW'], stdout=subprocess.PIPE)
stdout, stderr = root.communicate()
m = re.search(b'^_NET_ACTIVE_WINDOW.* ([\w]+)$', stdout)
if m != None:
window_id = m.group(1)
window = subprocess.Popen(['xprop', '-id', window_id, 'WM_CLASS'], stdout=subprocess.PIPE)
stdout, stderr = window.communicate()
else:
return None
match = re.match(b'WM_CLASS\(\w+\) = ".*", (?P<name>.+)$', stdout)
if match != None:
return match.group("name").strip(b'"')
return None
if __name__ == "__main__":
print(get_active_window_title())