Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meta-Issue for fixing issues with outdated dependencies. #68

Open
bf-ckiendl opened this issue Oct 18, 2019 · 3 comments
Open

Meta-Issue for fixing issues with outdated dependencies. #68

bf-ckiendl opened this issue Oct 18, 2019 · 3 comments

Comments

@bf-ckiendl
Copy link

bf-ckiendl commented Oct 18, 2019

I have added a guide on how to install bots under Windows by specifically installing the old dependencies further below.

I'm creating this issue so we can collect workarounds necessary to get the currently deployed version running, in the interest of creating a single place for future users to find the necessary patches.

Pull requests sound nice in theory, but if any significant work had been done, the latest release would not be from 2016.

In the interest of working around #67, I went through the following steps to get bots running:

Install Python 2.7 from official packages (python-2.7.16.amd64.msi in my case)

python -m pip install CherryPy Django Genshi bots

Alter permissions of C:\Python27\Lib\site-packages\bots to add change/modify permissions to Authenticated Users
Copy bots.ini, settings.py and settings.pyc from C:\Python27\Lib\site-packages\bots\install to C:\Python27\Lib\site-packages\bots\config, overwriting the existing files.

Create the folder C:\Python27\Lib\site-packages\bots\botssys\sqlitedb.
botssys might already exist but be hidden.
Copy the file C:\Python27\Lib\site-packages\bots\install\botsdb to C:\Python27\Lib\site-packages\bots\botssys\sqlitedb\botsdb

Edit C:\Python27\lib\site-packages\bots\webserver.py, line 12:
change

from cherrypy import wsgiserver

to

from cheroot.wsgi import Server as wsgiserver, PathInfoDispatcher

Line 54:
change

dispatcher = wsgiserver.WSGIPathInfoDispatcher({'/': servedjango, str('/media'): servestaticfiles}) #UNICODEPROBLEM: needs to be binary

to

dispatcher = PathInfoDispatcher({'/': servedjango, str('/media'): servestaticfiles}) #UNICODEPROBLEM: needs to be binary

Line 55:
change

botswebserver = wsgiserver.CherryPyWSGIServer(bind_addr=('0.0.0.0', botsglobal.ini.getint('webserver','port',8080)), wsgi_app=dispatcher, server_name=botsglobal.ini.get('webserver','name','bots-webserver'))

to

botswebserver = wsgiserver(bind_addr=('0.0.0.0', botsglobal.ini.getint('webserver','port',8080)), wsgi_app=dispatcher, server_name=botsglobal.ini.get('webserver','name','bots-webserver'))

Edit C:\Python27\lib\site-packages\bots\urls.py, line 2:
change

from django.conf.urls import patterns,include,url

to

from django.conf.urls import include,url

Line 12:
change

urlpatterns = patterns('',

to

urlpatterns = [

Line 44:
change

    )

to

    ]

Line 5:
Add

from django.contrib.auth.views import login, logout, password_change, password_change_done
from bots.views import index

moving

from . import views

down to line 7.
Line 15-18:
Replace with:

    url(r'^login.*', login, {'template_name': 'admin/login.html'}),
    url(r'^logout.*', logout,{'next_page': '/'}),
    url(r'^password_change/$', password_change, name='password_change'),
    url(r'^password_change/done/$', password_change_done,name='password_change_done'),

Line 45:
change

    url(r'^.*', 'bots.views.index'),

to

    url(r'^.*', index),

Edit C:\Python27\lib\site-packages\bots\pluglib.py, line 23 and line 48:
change

@django.db.transaction.commit_on_success  #if no exception raised: commit, else rollback.

to

@django.db.transaction.atomic  #if no exception raised: commit, else rollback.

Edit C:\Python27\lib\site-packages\bots\admin.py:
Insert a new line 93 (shift def clean(self) down to 94) and set it to fields = "__all__", properly indented to match the preceeding lines.
Insert a new line 193 (shift def clean(self) down to 194) and set it to fields = "__all__", properly indented to match the preceeding lines.
Insert a new line 226 (shift def clean(self) down to 227) and set it to fields = "__all__", properly indented to match the preceeding lines.

Edit C:\Python27\Lib\site-packages\bots\config\settings.py, line 106-111:
replace with

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(PROJECT_PATH, 'templates')],
    },
]

Edit C:\Python27\Lib\site-packages\bots\pluglib.py:
Line 202:
Change

table = django.db.models.get_model('bots',plugintype)

to

table = django.apps.apps.get_model('bots',plugintype)

Line 336:
Change

table = django.db.models.get_model(app,tablename)

to

table = django.apps.apps.get_model(app,tablename)

Lines 231 and 240:
Change

fieldobject = table._meta.get_field_by_name(fieldname)[0]

to

fieldobject = table._meta.get_field(fieldname)

Edit C:\Python27\lib\site-packages\bots\templates\admin\base.html, line 1:
Change

{% load admin_static %}{% load url from future %}<!DOCTYPE html>

to

{% load admin_static %}<!DOCTYPE html>

Then run bots-webserver.py.

I am now at a point where the webserver is running, but it shows me an empty homepage. It lets me go through to the django admin login page and lets me log in.

I'll have to see how much of the actual functionality is given.

Anyone who figures out additional fixes (e.g. for the port issue) is wholeheartedly invited to join in.

Package versions:
bots 3.3.0
cheroot 8.2.1
CherryPy 17.4.2
Django 1.11.25
Genshi 0.7.3

All running on Windows Server 2016.

P.S.: Don't tell me to attach a diff/patch. The point is to allow people to manually fix the installation by following along.

@eino-makitalo
Copy link

Also installation fails missing files

`(env) d:\myvirtualenv>pip install bots
Downloading/unpacking bots
Running setup.py (path:d:\myvirtualenv\build\bots\setup.py) egg_info for package
bots
Traceback (most recent call last):
File "", line 17, in
File "d:\myvirtualenv\build\bots\setup.py", line 54, in
'\n\n' +
File "d:\myvirtualenv\build\bots\setup.py", line 46, in read
with io.open(fn, encoding=kwargs.get('encoding', 'utf8')) as fd:
FileNotFoundError: [Errno 2] No such file or directory: 'D:\meyer\env\bui
ld\bots\readme.rst'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "", line 17, in

File "d:\myvirtualenv\build\bots\setup.py", line 54, in

'\n\n' +

File "d:\myvirtualenv\build\bots\setup.py", line 46, in read

with io.open(fn, encoding=kwargs.get('encoding', 'utf8')) as fd:

FileNotFoundError: [Errno 2] No such file or directory: 'D:\meyer\env\build\
bots\readme.rst'


Cleaning up...`

@bf-ckiendl
Copy link
Author

bf-ckiendl commented Oct 22, 2019

Figured out the port issue. The default config files need to be replaced with the ones from the install folder. I've updated the original post accordingly.

Bots-webserver is now running under 8080 as expected.

I'm still missing the actual application menus in the web frontend.

Edit: I can get to the individual screens by opening the URLs directly. I suspect the lack of menu items to be an issue with the template(s).
There seems to be an overall permission issue with the templates folder.
If I try to use io.open manually, it works just fine. Within bots, it's giving me permission errors.
The implication is, that I would need an elevated prompt.
I haven't figured out why yet.

Edit 2: There's an issue with the static files. Cherrypy served both WSGI and static, cheroot doesn't. So right now, /media/ isn't served.

Edit 3: Issue with plugin installation:
Resolved, see changes in OP.

@bf-ckiendl
Copy link
Author

Alternative installation guide, trying to work around the issues I had with the current-version-approach up top.

Install Python 2.7 from official packages (python-2.7.16.amd64.msi in my case).

Install virtualenv.

pip install virtualenv

In a regular (non-elevated, non-administrative) shell, go to your home folder:

cd /d %HOMEDRIVE%%HOMEPATH%

Create a folder for bots's environment:

md bots

Change into that folder:

cd bots

Create a virtual environment:

virtualenv env

Activate the virtual environment:

.\env\Scripts\activate.bat

Install bots and dependencies in the required versions:

python -m pip install CherryPy==3.2.4 Django==1.6.2 Genshi==0.7 bots

Copy bots.ini and settings.py from %HOMEDRIVE%%HOMEPATH%bots\env\Lib\site-packages\bots\install to %HOMEDRIVE%%HOMEPATH%bots\env\Lib\site-packages\bots\config, overwriting the existing files.
Delete %HOMEDRIVE%%HOMEPATH%bots\env\Lib\site-packages\bots\config\settings.pyc.

Create the database folder:

md %HOMEDRIVE%%HOMEPATH%bots\env\Lib\site-packages\bots\botssys\sqlitedb

Copy the file %HOMEDRIVE%%HOMEPATH%bots\env\Lib\site-packages\bots\install\botsdb to the database folder (%HOMEDRIVE%%HOMEPATH%bots\env\Lib\site-packages\bots\botssys\sqlitedb\botsdb).

Run the webserver:
%HOMEDRIVE%%HOMEPATH%bots\env\Scripts\python.exe %HOMEDRIVE%%HOMEPATH%bots\env\Scripts\bots-webserver.py

Bots should now be available at http://localhost:8080/.

I have not tested actual translation yet, but unlike trying to run with current versions, this installation at least shows the web interface properly.

Obvious drawback is the use of ancient dependency versions. DO NOT expose this installation, especially not to the Internet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants