rmcontrol icon indicating copy to clipboard operation
rmcontrol copied to clipboard

Issue with export FLASK_APP=rmcontrol; python -m flask initdb

Open luketoh opened this issue 8 years ago • 6 comments

pi@hassbian:/home/rmcontrol $ export FLASK_APP=rmcontrol; python -m flask initdbTraceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main "main", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/usr/local/lib/python2.7/dist-packages/Flask-0.12-py2.7.egg/flask/main.py", line 15, in main(as_module=True) File "/usr/local/lib/python2.7/dist-packages/Flask-0.12-py2.7.egg/flask/cli.py", line 507, in main cli.main(args=args, prog_name=name) File "/usr/local/lib/python2.7/dist-packages/Flask-0.12-py2.7.egg/flask/cli.py", line 374, in main return AppGroup.main(self, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/core.py", line 697, in main rv = self.invoke(ctx) File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/core.py", line 1066, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/core.py", line 895, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/core.py", line 535, in invoke return callback(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/decorators.py", line 17, in new_func return f(get_current_context(), *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/Flask-0.12-py2.7.egg/flask/cli.py", line 251, in decorator return __ctx.invoke(f, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/click-6.7-py2.7.egg/click/core.py", line 535, in invoke return callback(*args, **kwargs) File "rmcontrol/init.py", line 44, in initdb_command init_db() File "rmcontrol/init.py", line 32, in init_db db = get_db() File "rmcontrol/init.py", line 65, in get_db g.sqlite_db = connect_db() File "rmcontrol/init.py", line 53, in connect_db db = sqlite3.connect(os.path.join(app.root_path, 'database/rmcontrol.db')) sqlite3.OperationalError: unable to open database file

luketoh avatar Feb 18 '17 12:02 luketoh

By the way, I checked this folder and there isn't a rmcontrol.db file.

pi@hassbian:/home/rmcontrol/rmcontrol/database $ ls schema.sql

Maybe I something else didn't work and this database hadn't been created?

luketoh avatar Feb 18 '17 13:02 luketoh

I had some breakthrough, but it still isn't working or maybe I'm not understanding how it works. Anyway, I am running this on a Raspberry Pi. So the default user is pi. But when installing, I think most of the directories etc belong to root. So tried to chown -R pi:pi /home/rmcontrol/* and then tried the

export FLASK_APP=rmcontrol; python -m flask initdb

and this time it said the database was created.

but now when I try to run the script, I can get to the webpage, but I don't see anything happening. How do I do a simple test to know if everything is working as it should?

luketoh avatar Feb 18 '17 16:02 luketoh

Ahh, good call on the permissions.

If you see the "New command name", everything should be running correctly. Enter a name for your command, click the "+" sign, and then fire the remote toward your RM to learn the command (you will have 5 seconds after you click the "+" sign to fire the remote command). If the command was successfully learned, you will see it appear in the list above. Here's mine for example.

I apologize for the back usability. I wrote the front-end pretty quickly, and it definitely needs improvement.

Note: RM Control won't load commands from the official eControl app — you will have to teach RM Control all of the commands you'd like to use.

ericmagnuson avatar Feb 21 '17 22:02 ericmagnuson

@ericmagnuson thanks for creating this script though! Really useful now that I got to understand how to use it more. I have a question: How do you "patch" using the front end web ui? I understand how to enter the command and capture the remote code, as well as firing the code by clicking on a saved command. I also know how to delete an existing command, but there doesn't seem to be an easy way to "update/patch" an existing command and remote code?

Also one last question, is there a limit to the code length? I keep getting errors from my RF remote, but no issues with a TV remote using IR. No problem capturing the code...just errors appear when firing the code already saved in the database.

luketoh avatar Feb 22 '17 08:02 luketoh

@luketoh The patch API method hasn't yet been integrated on the front-end. That's high on the to-do list, though!

AFAIK, there is no limit to the code length. What error do you see in the console of the web app when you try to fire an RF code?

ericmagnuson avatar Feb 22 '17 22:02 ericmagnuson

@ericmagnuson @luketoh I'm a little confuse, what should I be doing after ~ $ sudo python setup.py install

I ran export FLASK_APP=rmcontrol; python -m flask initdb but getting the following error. So I did what Luke said to ran -R pi:pi /home/rmcontrol/* still no joy.

pi@raspberrypi:~ $ git clone https://github.com/ericmagnuson/rmcontrol.git && cd rmcontrol
fatal: destination path 'rmcontrol' already exists and is not an empty directory.
pi@raspberrypi:~ $ sudo python setup.py install
python: can't open file 'setup.py': [Errno 2] No such file or directory
pi@raspberrypi:~ $ export FLASK_APP=rmcontrol; python -m flask initdb
/usr/bin/python: No module named flask.__main__; 'flask' is a package and cannot be directly executed
pi@raspberrypi:~ $ 
pi@raspberrypi:~ $ sudo -R pi:pi /home/rmcontrol/*
sudo: invalid option -- 'R'
usage: sudo -h | -K | -k | -V
usage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]
usage: sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user]
            [command]
usage: sudo [-AbEHknPS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p
            prompt] [-u user] [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p
            prompt] [-u user] file ...

jeylites avatar Apr 26 '17 03:04 jeylites