Subprocess maximum recursion depth exceeded
up vote
0
down vote
favorite
I am trying to current playing track name from Spotify desktop app window title by using subprocess. In generally, my code is working. But when trying to retrieve song name each five second, i get RecursionError. Where is the problem?
Code1
def title_of_window(self,window_class):
"""
Retrieves the title of application by through 'subprocess'.
Params:
window_class (string) -- name of the application to be taken the title
ex. --> spotify
--> filezilla
--> putty
--> atom
For this app:
- window_class parameter must be equal to "spotify"
- Retrieves the current playing song name from Spotify.
"""
# Finds id of all GUI apps who running.
# Ex. -> ['0x200000a', '0x3800007', '0x4800001', '0x2e00010', '0x3600001n']
active_windows = subprocess.Popen(["xprop",
"-root",
"_NET_CLIENT_LIST_STACKING"],
stdout=subprocess.PIPE).communicate()
active_windows_ids = active_windows[0].decode("utf-8").split("# ")[1].split(", ")
#
# Sends all ids to 'xprop -id' and checks. If app name equal to window_class parameter, return title of this app.
# Ex. -> get_window.py — ~/Desktop/projects — Atom
for active_id in active_windows_ids:
window = subprocess.Popen(["xprop",
"-id",
active_id.strip(),
"WM_CLASS",
"_NET_WM_NAME"],
stdout=subprocess.PIPE).communicate()
window = window[0].decode("utf-8").split('"')
if window_class == window[3].lower():
return window[5]
Mainloop
def run(self):
song = self.title_of_window(self.SPOTIFY)
if self.temp_song_name != song:
lyric = self.get_lyric(song)
self.add_lyric_to_tk(song,lyric)
else:
self.add_lyric_to_tk(song, "Not Found")
self.top.after(5000,self.run)
self.top.mainloop()
Error:
File "spotifyLyric.py", line 137, in run
song = self.title_of_window(self.SPOTIFY)
File "spotifyLyric.py", line 51, in title_of_window
stdout=subprocess.PIPE).communicate()
RecursionError: maximum recursion depth exceeded while calling a Python object
python recursion subprocess
add a comment |
up vote
0
down vote
favorite
I am trying to current playing track name from Spotify desktop app window title by using subprocess. In generally, my code is working. But when trying to retrieve song name each five second, i get RecursionError. Where is the problem?
Code1
def title_of_window(self,window_class):
"""
Retrieves the title of application by through 'subprocess'.
Params:
window_class (string) -- name of the application to be taken the title
ex. --> spotify
--> filezilla
--> putty
--> atom
For this app:
- window_class parameter must be equal to "spotify"
- Retrieves the current playing song name from Spotify.
"""
# Finds id of all GUI apps who running.
# Ex. -> ['0x200000a', '0x3800007', '0x4800001', '0x2e00010', '0x3600001n']
active_windows = subprocess.Popen(["xprop",
"-root",
"_NET_CLIENT_LIST_STACKING"],
stdout=subprocess.PIPE).communicate()
active_windows_ids = active_windows[0].decode("utf-8").split("# ")[1].split(", ")
#
# Sends all ids to 'xprop -id' and checks. If app name equal to window_class parameter, return title of this app.
# Ex. -> get_window.py — ~/Desktop/projects — Atom
for active_id in active_windows_ids:
window = subprocess.Popen(["xprop",
"-id",
active_id.strip(),
"WM_CLASS",
"_NET_WM_NAME"],
stdout=subprocess.PIPE).communicate()
window = window[0].decode("utf-8").split('"')
if window_class == window[3].lower():
return window[5]
Mainloop
def run(self):
song = self.title_of_window(self.SPOTIFY)
if self.temp_song_name != song:
lyric = self.get_lyric(song)
self.add_lyric_to_tk(song,lyric)
else:
self.add_lyric_to_tk(song, "Not Found")
self.top.after(5000,self.run)
self.top.mainloop()
Error:
File "spotifyLyric.py", line 137, in run
song = self.title_of_window(self.SPOTIFY)
File "spotifyLyric.py", line 51, in title_of_window
stdout=subprocess.PIPE).communicate()
RecursionError: maximum recursion depth exceeded while calling a Python object
python recursion subprocess
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to current playing track name from Spotify desktop app window title by using subprocess. In generally, my code is working. But when trying to retrieve song name each five second, i get RecursionError. Where is the problem?
Code1
def title_of_window(self,window_class):
"""
Retrieves the title of application by through 'subprocess'.
Params:
window_class (string) -- name of the application to be taken the title
ex. --> spotify
--> filezilla
--> putty
--> atom
For this app:
- window_class parameter must be equal to "spotify"
- Retrieves the current playing song name from Spotify.
"""
# Finds id of all GUI apps who running.
# Ex. -> ['0x200000a', '0x3800007', '0x4800001', '0x2e00010', '0x3600001n']
active_windows = subprocess.Popen(["xprop",
"-root",
"_NET_CLIENT_LIST_STACKING"],
stdout=subprocess.PIPE).communicate()
active_windows_ids = active_windows[0].decode("utf-8").split("# ")[1].split(", ")
#
# Sends all ids to 'xprop -id' and checks. If app name equal to window_class parameter, return title of this app.
# Ex. -> get_window.py — ~/Desktop/projects — Atom
for active_id in active_windows_ids:
window = subprocess.Popen(["xprop",
"-id",
active_id.strip(),
"WM_CLASS",
"_NET_WM_NAME"],
stdout=subprocess.PIPE).communicate()
window = window[0].decode("utf-8").split('"')
if window_class == window[3].lower():
return window[5]
Mainloop
def run(self):
song = self.title_of_window(self.SPOTIFY)
if self.temp_song_name != song:
lyric = self.get_lyric(song)
self.add_lyric_to_tk(song,lyric)
else:
self.add_lyric_to_tk(song, "Not Found")
self.top.after(5000,self.run)
self.top.mainloop()
Error:
File "spotifyLyric.py", line 137, in run
song = self.title_of_window(self.SPOTIFY)
File "spotifyLyric.py", line 51, in title_of_window
stdout=subprocess.PIPE).communicate()
RecursionError: maximum recursion depth exceeded while calling a Python object
python recursion subprocess
I am trying to current playing track name from Spotify desktop app window title by using subprocess. In generally, my code is working. But when trying to retrieve song name each five second, i get RecursionError. Where is the problem?
Code1
def title_of_window(self,window_class):
"""
Retrieves the title of application by through 'subprocess'.
Params:
window_class (string) -- name of the application to be taken the title
ex. --> spotify
--> filezilla
--> putty
--> atom
For this app:
- window_class parameter must be equal to "spotify"
- Retrieves the current playing song name from Spotify.
"""
# Finds id of all GUI apps who running.
# Ex. -> ['0x200000a', '0x3800007', '0x4800001', '0x2e00010', '0x3600001n']
active_windows = subprocess.Popen(["xprop",
"-root",
"_NET_CLIENT_LIST_STACKING"],
stdout=subprocess.PIPE).communicate()
active_windows_ids = active_windows[0].decode("utf-8").split("# ")[1].split(", ")
#
# Sends all ids to 'xprop -id' and checks. If app name equal to window_class parameter, return title of this app.
# Ex. -> get_window.py — ~/Desktop/projects — Atom
for active_id in active_windows_ids:
window = subprocess.Popen(["xprop",
"-id",
active_id.strip(),
"WM_CLASS",
"_NET_WM_NAME"],
stdout=subprocess.PIPE).communicate()
window = window[0].decode("utf-8").split('"')
if window_class == window[3].lower():
return window[5]
Mainloop
def run(self):
song = self.title_of_window(self.SPOTIFY)
if self.temp_song_name != song:
lyric = self.get_lyric(song)
self.add_lyric_to_tk(song,lyric)
else:
self.add_lyric_to_tk(song, "Not Found")
self.top.after(5000,self.run)
self.top.mainloop()
Error:
File "spotifyLyric.py", line 137, in run
song = self.title_of_window(self.SPOTIFY)
File "spotifyLyric.py", line 51, in title_of_window
stdout=subprocess.PIPE).communicate()
RecursionError: maximum recursion depth exceeded while calling a Python object
python recursion subprocess
python recursion subprocess
asked 2 days ago
Batuhan Gürses
34
34
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
The problem is that you're calling self.top.mainloop()
multiple times. You should be able to fix the error by moving the call to self.top.mainloop()
into your __init__()
method.
def __init__(self):
...
self.run()
self.top.mainloop()
def run(self):
song = self.title_of_window(self.SPOTIFY)
if self.temp_song_name != song:
lyric = self.get_lyric(song)
self.add_lyric_to_tk(song,lyric)
else:
self.add_lyric_to_tk(song, "Not Found")
self.top.after(5000,self.run)
Does this solve your problem?
EDIT: see here for a longer description of the problem.
Yes, solved!! I understand what my problem is. Thank you so much...
– Batuhan Gürses
2 days ago
You're welcome! Glad that I could help
– Felix
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
The problem is that you're calling self.top.mainloop()
multiple times. You should be able to fix the error by moving the call to self.top.mainloop()
into your __init__()
method.
def __init__(self):
...
self.run()
self.top.mainloop()
def run(self):
song = self.title_of_window(self.SPOTIFY)
if self.temp_song_name != song:
lyric = self.get_lyric(song)
self.add_lyric_to_tk(song,lyric)
else:
self.add_lyric_to_tk(song, "Not Found")
self.top.after(5000,self.run)
Does this solve your problem?
EDIT: see here for a longer description of the problem.
Yes, solved!! I understand what my problem is. Thank you so much...
– Batuhan Gürses
2 days ago
You're welcome! Glad that I could help
– Felix
2 days ago
add a comment |
up vote
0
down vote
accepted
The problem is that you're calling self.top.mainloop()
multiple times. You should be able to fix the error by moving the call to self.top.mainloop()
into your __init__()
method.
def __init__(self):
...
self.run()
self.top.mainloop()
def run(self):
song = self.title_of_window(self.SPOTIFY)
if self.temp_song_name != song:
lyric = self.get_lyric(song)
self.add_lyric_to_tk(song,lyric)
else:
self.add_lyric_to_tk(song, "Not Found")
self.top.after(5000,self.run)
Does this solve your problem?
EDIT: see here for a longer description of the problem.
Yes, solved!! I understand what my problem is. Thank you so much...
– Batuhan Gürses
2 days ago
You're welcome! Glad that I could help
– Felix
2 days ago
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
The problem is that you're calling self.top.mainloop()
multiple times. You should be able to fix the error by moving the call to self.top.mainloop()
into your __init__()
method.
def __init__(self):
...
self.run()
self.top.mainloop()
def run(self):
song = self.title_of_window(self.SPOTIFY)
if self.temp_song_name != song:
lyric = self.get_lyric(song)
self.add_lyric_to_tk(song,lyric)
else:
self.add_lyric_to_tk(song, "Not Found")
self.top.after(5000,self.run)
Does this solve your problem?
EDIT: see here for a longer description of the problem.
The problem is that you're calling self.top.mainloop()
multiple times. You should be able to fix the error by moving the call to self.top.mainloop()
into your __init__()
method.
def __init__(self):
...
self.run()
self.top.mainloop()
def run(self):
song = self.title_of_window(self.SPOTIFY)
if self.temp_song_name != song:
lyric = self.get_lyric(song)
self.add_lyric_to_tk(song,lyric)
else:
self.add_lyric_to_tk(song, "Not Found")
self.top.after(5000,self.run)
Does this solve your problem?
EDIT: see here for a longer description of the problem.
answered 2 days ago
Felix
2,1392826
2,1392826
Yes, solved!! I understand what my problem is. Thank you so much...
– Batuhan Gürses
2 days ago
You're welcome! Glad that I could help
– Felix
2 days ago
add a comment |
Yes, solved!! I understand what my problem is. Thank you so much...
– Batuhan Gürses
2 days ago
You're welcome! Glad that I could help
– Felix
2 days ago
Yes, solved!! I understand what my problem is. Thank you so much...
– Batuhan Gürses
2 days ago
Yes, solved!! I understand what my problem is. Thank you so much...
– Batuhan Gürses
2 days ago
You're welcome! Glad that I could help
– Felix
2 days ago
You're welcome! Glad that I could help
– Felix
2 days ago
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53350344%2fsubprocess-maximum-recursion-depth-exceeded%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown