Reputation: 13
i'm trying to pipe some lines with icons to rofi but i'm getting this errror and i don't understand why
def show_podcasts(f):
podcasts_list = ""
with open(f,"r") as podcasts:
for line in podcasts:
episode_title = " ".join(line.split(" ")[:-2])
found = False
for pic in os.listdir("images"):
if os.path.isfile(os.path.join("images",pic)):
if pic.startswith(episode_title):
found = True
podcasts_list += episode_title + "\x00icon\x1f" + pic + "\n"
if not found:
podcasts_list += episode_title + "\n"
print(podcasts_list)
selected_podcast = os.popen("(cat << EOF\n" + podcasts_list + "EOF\n)| rofi -dmenu -p 'enter the podcast you are looking for'").read()
and this is the error
Traceback (most recent call last):
File "/home/javier/ssd/dev/python/pod-rofi/main.py", line 91, in <module>
main()
File "/home/javier/ssd/dev/python/pod-rofi/main.py", line 84, in main
show_podcasts("podcasts")
File "/home/javier/ssd/dev/python/pod-rofi/main.py", line 77, in show_podcasts
selected_podcast = os.popen("(cat << EOF\n" + podcasts_list + "EOF\n)| rofi -dmenu -p 'enter the podcast you are looking for'").read()
File "/usr/lib/python3.10/os.py", line 985, in popen
proc = subprocess.Popen(cmd,
File "/usr/lib/python3.10/subprocess.py", line 966, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.10/subprocess.py", line 1775, in _execute_child
self.pid = _posixsubprocess.fork_exec(
ValueError: embedded null byte
Upvotes: 0
Views: 370
Reputation: 17267
I don't understand what exactly you want to do, but hope it helps if I explain the error.
Running a program involves a system call and the interface follows the C-language rule that a string (in this case the command) is terminated by a null-byte. The rule implies that a null byte cannot be one of the characters.
But here gets the null byte inserted:
podcasts_list += episode_title + "\x00icon\x1f" + ....
# ^^^^
Upvotes: 0