6

17 comments

[–] E-werd 1 points (+1|-0)

Stand by on this one. I see what the issue is but it's odd that it's coming up to me. I'll have to give it a try again.

[–] curious [OP] 0 points (+0|-0) Edited

So close, yet so far. Almost there, but NOT yet!

So the migrate.py file is ONLY for migrating from an existing installation of phuks to the latest code base and NOT for a fresh installation of Phuks.

The installation steps will have already created a throat database for you. However, this is not the database you need. You need the database of your existing Phuks installation.

For this, create a copy of your existing Phuks database and name it say, throat2. Export it as, say throat2.sql and create a copy of your Phuks database. You'll use this sql file to create a new database where you want to install phuks.

Follow the steps in this article to copy and export sql databases.

Once you've created a throat2 database, import the throat2 database using the throat2.sql file to the database throat2.

Once you've imported the database, on the config.py file, replace throat with throat2 since we will be using the throat2 database now.

DATABASE = {
    'host': 'localhost',
    'name': 'throat2',
    'engine': 'MySQLDatabase',
    'user': 'debian-sys-maint',
    'password': '5oCNi3MRmSXRxJFI',
}

Once done, run the ./migrate.py script and you'll have the following output.

Starting migrations
Migrate "001_initial"
Done 001_initial
Migrate "002_subcreation"
Done 002_subcreation
Migrate "003_submod"
Done 003_submod
Migrate "004_subban"
Done 004_subban
Migrate "005_banreasonlength"
change_column ('sub_ban', 'reason', <CharField: SubBan.reason>)
Done 005_banreasonlength
Migrate "006_comment_history"
Done 006_comment_history

After the above commands are executed type cd..

Next, I type nano wsgi.py and the file is opened.

#!/usr/bin/env python3
""" From here we start the app in debug mode. """
import eventlet
eventlet.monkey_patch()

from app import app, socketio  # noqa
if __name__ == "__main__":
    socketio.run(app, debug=True)

I do nothing with this file and move on to the next step, which is run the following command.

./wsgi.py

The following output is displayed on my terminal .

​```
INFO:werkzeug: * Restarting with stat
WARNING:werkzeug: * Debugger is active!
INFO:werkzeug: * Debugger PIN: 336-192-212
(6555) wsgi starting up on http://127.0.0.1:5000
​```

I navigate to http://127.0.0.1:5000 but I'm getting the following AttributeError page on the browser. What should I do next @E-werd?

AttributeError Screenshot

This is what the console shows me.

INFO:werkzeug: * Debugger PIN: 336-192-212
(6555) wsgi starting up on http://127.0.0.1:5000
(6555) accepted ('127.0.0.1', 56636)
DEBUG:peewee:('SELECT `t1`.`nsfw`, `t1`.`content`, `t1`.`pid`, `t1`.`title`, `t1`.`posted`, `t1`.`deleted`, `t1`.`score`, `t1`.`ptype`, `t1`.`thumbnail`, `t1`.`link`, `t2`.`name` AS `user`, `t3`.`name` AS `sub`, `t1`.`flair`, `t1`.`edited`, `t3`.`sid`, `t1`.`comments`, `t2`.`uid`, `t2`.`status` AS `userstatus` FROM `sub_post` AS `t1` LEFT OUTER JOIN `user` AS `t2` ON (`t1`.`uid` = `t2`.`uid`) LEFT OUTER JOIN `sub` AS `t3` ON (`t1`.`sid` = `t3`.`sid`) LEFT OUTER JOIN `site_metadata` AS `t4` ON (`t4`.`key` = %s) WHERE (((`t1`.`deleted` = %s) AND (`t1`.`nsfw` = %s)) AND (`t1`.`sid` = `t4`.`value`)) ORDER BY ((`t1`.`score` * %s) + ((Unix_Timestamp(`t1`.`posted`) - %s) / %s)) DESC LIMIT %s OFFSET %s', ['default', 0, False, 20, 1134028003, 1500, 25, 0])
Traceback (most recent call last):
  File "/home/app/.pyenv/versions/3.5.2/envs/app/lib/python3.5/site-packages/flask/app.py", line 2449, in wsgi_app
    response = self.handle_exception(e)
  File "/home/app/.pyenv/versions/3.5.2/envs/app/lib/python3.5/site-packages/flask/app.py", line 1866, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/app/.pyenv/versions/3.5.2/envs/app/lib/python3.5/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/app/.pyenv/versions/3.5.2/envs/app/lib/python3.5/site-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/app/.pyenv/versions/3.5.2/envs/app/lib/python3.5/site-packages/flask/app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/app/.pyenv/versions/3.5.2/envs/app/lib/python3.5/site-packages/flask/app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/app/.pyenv/versions/3.5.2/envs/app/lib/python3.5/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/app/.pyenv/versions/3.5.2/envs/app/lib/python3.5/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/app/.pyenv/versions/3.5.2/envs/app/lib/python3.5/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/app/throat/app/__init__.py", line 148, in index
    return home_hot(1)
  File "/home/app/throat/app/__init__.py", line 157, in home_hot
    'subOfTheDay': misc.getSubOfTheDay(),
  File "/home/app/.pyenv/versions/3.5.2/envs/app/lib/python3.5/site-packages/flask_caching/__init__.py", line 795, in decorated_function
    rv = f(*args, **kwargs)
  File "/home/app/throat/app/misc.py", line 696, in getSubOfTheDay
    daysub = Sub.select(Sub.sid, Sub.name, Sub.title).order_by(db.random()).get()
  File "/home/app/.pyenv/versions/3.5.2/envs/app/lib/python3.5/site-packages/peewee.py", line 439, in __getattr__
    return getattr(self.obj, attr)
AttributeError: 'MySQLDatabase' object has no attribute 'random'
127.0.0.1 - - [07/Aug/2019 08:30:31] "GET / HTTP/1.1" 500 26122 0.070092
127.0.0.1 - - [07/Aug/2019 08:30:31] "GET /?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1" 200 6745 0.001529
(6555) accepted ('127.0.0.1', 56638)
(6555) accepted ('127.0.0.1', 56639)
127.0.0.1 - - [07/Aug/2019 08:30:31] "GET /?__debugger__=yes&cmd=resource&f=jquery.js HTTP/1.1" 200 88301 0.000898
127.0.0.1 - - [07/Aug/2019 08:30:31] "GET /?__debugger__=yes&cmd=resource&f=debugger.js HTTP/1.1" 200 6555 0.001083
127.0.0.1 - - [07/Aug/2019 08:30:31] "GET /?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 633 0.000852
127.0.0.1 - - [07/Aug/2019 08:30:31] "GET /?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 633 0.000714