0

I'm building a flatpak builded project. I have a button, when it is clicked I want it to run a scrapy script to crawl data.
window.ui

<object class="GtkButton" id="reload_btn">
                            <property name="label" translatable="yes">Reload data</property>
                            <signal name="clicked" handler="on_reload_btn_clicked" swapped="no"/>
</object>

window.py

import subprocess
@Gtk.Template.Callback()
    def on_reload_btn_clicked(self,button):
         name = "province"
         process.call(["scrapy",'crawl','province','-O /home/huydq/ITSS Linux/CovidTracking/provinces/province.json'],cwd='/home/huydq/ITSS Linux/CovidTracking/provinces',shell=True)

The structure of project is like:

/home/huydq/Projects/CovidTracking
└───provinces
│   └───spiders
│       │   province.py
│   └───province.json
└───src
    │   window.py
    │   window.ui

I tried to make a test.py file to run subprocess.call with the above command, it works fine. But when I run project it gets following error:

crawl: line 1: scrapy: command not found

  • Guess you need someone to help you with a more specific solution, but from what I'm observing, the problem maybe be around your subprocess.call. Because whenever you run, it'll fire an error that said No such file or directory: 'scrapy', which means that the file or the directory maybe doesn't exist at first or you directory it wrong way I think. – Bunny Dec 25 '21 at 04:23
  • I try to create a test file and run the subprocess.call and it works I'm confused bc it doesn't work when run flatpak project – Đỗ Quang Huy Dec 26 '21 at 15:41
  • I edited my question. I just add "shell = True" to my subprocess call but it appears like I have to add scrapy to my project which I also have some problems here: https://stackoverflow.com/questions/70477611/error-when-adding-scrapy-to-flatpak-project – Đỗ Quang Huy Dec 26 '21 at 17:49

0 Answers0