Skip to content

Commit ef47eb5

Browse files
committed
Get PQR up and running again
Due to lack of maintenance, the codebase has become outdated. I was unable to build it as is on Ubuntu 22.04. This PR has the minimal changes I needed to get the server up and running again. 1) Update to Python 2.7.18. Older versions of Python cannot be built. 2) The latest versions of Flask are incompatible with Python 2 and existing code. So, Pin dependency versions of Flask and related deps. 3) Remove a secret_config import as the file is not present in the repo. 4) Install lesshat using npm and update lesshat imports. 5) Update gulp and related imports. 6) Fix code in bindevents.js to make gulp build pass.
1 parent 5100ff2 commit ef47eb5

File tree

10 files changed

+37
-34
lines changed

10 files changed

+37
-34
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ PQR is built upon Flask, a lightweight MVC in Python. PQR also uses MongoDB. We
88

99
To run PQR locally, do the following:
1010
1. Clone this repository
11-
2. Make sure you have Python 2.7.6 or Python 2.7.9
11+
2. Make sure you have Python 2.7.18.
1212
3. Install `virtualenv`. On Debian systems, run `sudo pip install virtualenv`. On Windows, `pip install virtualenv`
1313
4. Make sure you are in the root of the repo, aka the same level as this README. Then, run `virtualenv venv`. This will create a virtual environment named `venv` in the root of the repo.
1414
5. On Linux systems, run `. venv/bin/activate` to activate the virtual enviroment. On Windows, run `.\venv\Scripts\activate`.

assets/js/bindevents.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,13 @@ module.exports = (function() {
176176
if ($(selector).length) {
177177
$(selector).on("click vclick", function(event) {
178178
event.preventDefault();
179-
if $(this).text()=="Remove Surface"{
179+
if ($(this).text()==="Remove Surface") {
180180
threeDMole.toggleSurface();
181181
$(this).addClass('btn-success');
182182
$(this).removeClass('btn-danger');
183183
$(this).html('Add Surface');
184184
//"feedback", "fa-desktop");
185-
}
186-
else {
185+
} else {
187186
threeDMole.toggleSurface2();
188187
$(this).addClass('btn-danger');
189188
$(this).removeClass('btn-success');

assets/style/main.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//Import bootstrap variables and mixins to use variables
2-
@import '../../bower_components/lesshat/build/lesshat.less';
2+
@import "node_modules/lesshat/lesshat.less";
33
@import (reference) "bootstrap/bootstrap.less";
44
@import "bootstrap/variables.less";
55
@import "bootstrap/mixins.less";

gulpfile.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
var gulp = require('gulp'),
3+
const gulp = require('gulp'),
44
path = require('path'),
55
concat = require('gulp-concat'),
66
autoprefixer = require('gulp-autoprefixer'),
@@ -16,9 +16,10 @@ var gulp = require('gulp'),
1616
uglify = require('gulp-uglify'),
1717
tape = require('gulp-tape'),
1818
watch = require('gulp-watch');
19-
var paths = {
20-
source : path.join(__dirname, 'assets/'),
21-
dist : path.join(__dirname, 'pqr/static/'),
19+
20+
const paths = {
21+
source: path.join(__dirname, 'assets/'),
22+
dist: path.join(__dirname, 'pqr/static/'),
2223
style: 'style/',
2324
js: 'js/',
2425
test: 'test/'
@@ -72,11 +73,11 @@ gulp.task('js', function () {
7273
.pipe(gulp.dest(paths.dist + paths.js));
7374
});
7475
});
75-
gulp.task('compile', ['less', 'js']);
76+
gulp.task('compile', gulp.series('less', 'js'));
7677
//test
7778
gulp.task('test', function() {
7879
return gulp.src(paths.source + paths.test + 'main.test.js')
7980
.pipe(tape());
8081
});
8182
//default
82-
gulp.task('default', ['compile']);
83+
gulp.task('default', gulp.series('compile'));

package.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,29 @@
66
"dependencies": {
77
"bootstrap": "^3.3.6",
88
"browsernizr": "^2.1.0",
9+
"lesshat": "^4.1.0",
910
"qrcode-npm": "0.0.3"
1011
},
1112
"devDependencies": {
1213
"babel-preset-es2015": "^6.5.0",
1314
"babelify": "^7.2.0",
1415
"browserify": "^13.0.0",
1516
"glob": "^6.0.4",
16-
"gulp": "^3.9.0",
17-
"gulp-autoprefixer": "^3.1.0",
18-
"gulp-concat": "^2.6.0",
19-
"gulp-cssnano": "^2.1.0",
20-
"gulp-jshint": "^2.0.0",
17+
"gulp": "4.0.2",
18+
"gulp-autoprefixer": "^8.0.0",
19+
"gulp-concat": "2.6.1",
20+
"gulp-cssnano": "^2.1.3",
21+
"gulp-jshint": "^2.1.0",
2122
"gulp-less": "^3.0.5",
2223
"gulp-sourcemaps": "^1.6.0",
23-
"gulp-tape": "0.0.7",
24-
"gulp-uglify": "^1.5.1",
24+
"gulp-tape": "1.0.0",
25+
"gulp-uglify": "3.0.2",
2526
"gulp-util": "^3.0.7",
2627
"gulp-watch": "^4.3.5",
2728
"jshint": "^2.9.1",
2829
"tape": "^4.4.0",
29-
"vinyl-buffer": "^1.0.0",
30-
"vinyl-source-stream": "^1.1.0"
30+
"vinyl-buffer": "^1.0.1",
31+
"vinyl-source-stream": "^2.0.0"
3132
},
3233
"scripts": {
3334
"postinstall": "bower install",

pqr/static/js/pqr.min.js

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pqr/static/style/pqr.min.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pqr/views.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from pymongo import MongoClient
1515

1616
# PQR specific imports
17-
from pqr import pqr, secret_config
17+
from pqr import pqr
1818

1919
from settings import APP_JSON, APP_MOL2, APP_ARTICLES
2020

@@ -658,6 +658,7 @@ def get_weekly_molecule_list():
658658
sunday = today - (today % 7)
659659
sunday = datetime.date.fromordinal(sunday)
660660
sunday = datetime.date.isoformat(sunday)
661+
last = None
661662
with open("./pqr/server_start/mol_of_the_week", "r") as molfile:
662663
for line in molfile:
663664

@@ -668,13 +669,15 @@ def get_weekly_molecule_list():
668669
tokens = line.strip().split(",")
669670
if len(tokens) < 3:
670671
continue
672+
673+
# inchikey, title, date
674+
last = tokens[1] + "," + tokens[2].title() + "," + tokens[0][0:4] + '-' + tokens[0][4:6] + '-' + tokens[0][6:]
671675
if tokens[0] <= datetime.datetime.isoformat(datetime.datetime.now()).replace('-', ''):
672-
return_list.append( # inchikey, title, date
673-
tokens[1] + "," + tokens[2].title() + "," + tokens[0][0:4] + '-' + tokens[0][4:6] + '-' + tokens[0][6:]
674-
)
676+
return_list.append(last)
677+
else: # We are now past the current date, don't show them yet
678+
continue
679+
return return_list or [last]
675680

676-
else: # We are now past the current date, don't show them yet
677-
return return_list
678681

679682
def get_json_data_file(key_first_two, key):
680683
try:

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
Flask
1+
Flask==0.11.0
2+
Werkzeug==0.16.1
23
pymongo
34
Flask-Cache
45
flask-mandrill

server.py

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!./venv/bin/python
1+
#!/usr/bin/env python
22
from pymongo import MongoClient
33
import datetime
44
import threading

0 commit comments

Comments
 (0)