Commit 422a2ded authored by Recteur LP's avatar Recteur LP

Merge CodeClimate CI Testing and Refactoring

parent e455caed
---
engines:
csslint:
enabled: true
duplication:
enabled: true
config:
languages:
- javascript
- python
eslint:
enabled: true
fixme:
enabled: true
radon:
enabled: true
config:
threshold: "C"
pep8:
enabled: true
ratings:
paths:
- "**.css"
- "**.inc"
- "**.js"
- "**.jsx"
- "**.module"
- "**.php"
- "**.py"
- "**.rb"
exclude_paths:
- dist/
- node_modules/
- env/
- build/
- html/
- src/build/
- pyrmin/static/css
- pyrmin/static/vendor
- pyrmin/static/js
\ No newline at end of file
**/*{.,-}min.js
---
parserOptions:
sourceType: module
ecmaFeatures:
jsx: true
env:
amd: true
browser: true
es6: true
jquery: true
node: true
# http://eslint.org/docs/rules/
rules:
# Possible Errors
no-await-in-loop: off
no-cond-assign: error
no-console: off
no-constant-condition: error
no-control-regex: error
no-debugger: error
no-dupe-args: error
no-dupe-keys: error
no-duplicate-case: error
no-empty-character-class: error
no-empty: error
no-ex-assign: error
no-extra-boolean-cast: error
no-extra-parens: off
no-extra-semi: error
no-func-assign: error
no-inner-declarations:
- error
- functions
no-invalid-regexp: error
no-irregular-whitespace: error
no-negated-in-lhs: error
no-obj-calls: error
no-prototype-builtins: off
no-regex-spaces: error
no-sparse-arrays: error
no-template-curly-in-string: off
no-unexpected-multiline: error
no-unreachable: error
no-unsafe-finally: off
no-unsafe-negation: off
use-isnan: error
valid-jsdoc: off
valid-typeof: error
# Best Practices
accessor-pairs: error
array-callback-return: off
block-scoped-var: off
class-methods-use-this: off
complexity:
- error
- 6
consistent-return: off
curly: off
default-case: off
dot-location: off
dot-notation: off
eqeqeq: error
guard-for-in: error
no-alert: error
no-caller: error
no-case-declarations: error
no-div-regex: error
no-else-return: off
no-empty-function: off
no-empty-pattern: error
no-eq-null: error
no-eval: error
no-extend-native: error
no-extra-bind: error
no-extra-label: off
no-fallthrough: error
no-floating-decimal: off
no-global-assign: off
no-implicit-coercion: off
no-implied-eval: error
no-invalid-this: off
no-iterator: error
no-labels:
- error
- allowLoop: true
allowSwitch: true
no-lone-blocks: error
no-loop-func: error
no-magic-number: off
no-multi-spaces: off
no-multi-str: off
no-native-reassign: error
no-new-func: error
no-new-wrappers: error
no-new: error
no-octal-escape: error
no-octal: error
no-param-reassign: off
no-proto: error
no-redeclare: error
no-restricted-properties: off
no-return-assign: error
no-return-await: off
no-script-url: error
no-self-assign: off
no-self-compare: error
no-sequences: off
no-throw-literal: off
no-unmodified-loop-condition: off
no-unused-expressions: error
no-unused-labels: off
no-useless-call: error
no-useless-concat: error
no-useless-escape: off
no-useless-return: off
no-void: error
no-warning-comments: off
no-with: error
prefer-promise-reject-errors: off
radix: error
require-await: off
vars-on-top: off
wrap-iife: error
yoda: off
# Strict
strict: off
# Variables
init-declarations: off
no-catch-shadow: error
no-delete-var: error
no-label-var: error
no-restricted-globals: off
no-shadow-restricted-names: error
no-shadow: off
no-undef-init: error
no-undef: off
no-undefined: off
no-unused-vars: off
no-use-before-define: off
# Node.js and CommonJS
callback-return: error
global-require: error
handle-callback-err: error
no-mixed-requires: off
no-new-require: off
no-path-concat: error
no-process-env: off
no-process-exit: error
no-restricted-modules: off
no-sync: off
# Stylistic Issues
array-bracket-spacing: off
block-spacing: off
brace-style: off
camelcase: off
capitalized-comments: off
comma-dangle:
- error
- never
comma-spacing: off
comma-style: off
computed-property-spacing: off
consistent-this: off
eol-last: off
func-call-spacing: off
func-name-matching: off
func-names: off
func-style: off
id-length: off
id-match: off
indent: off
jsx-quotes: off
key-spacing: off
keyword-spacing: off
line-comment-position: off
linebreak-style: off
lines-around-comment: off
lines-around-directive: off
max-depth: off
max-len: off
max-nested-callbacks: off
max-params: off
max-statements-per-line: off
max-statements:
- error
- 30
multiline-ternary: off
new-cap: off
new-parens: off
newline-after-var: off
newline-before-return: off
newline-per-chained-call: off
no-array-constructor: off
no-bitwise: off
no-continue: off
no-inline-comments: off
no-lonely-if: off
no-mixed-operators: off
no-mixed-spaces-and-tabs: off
no-multi-assign: off
no-multiple-empty-lines: off
no-negated-condition: off
no-nested-ternary: off
no-new-object: off
no-plusplus: off
no-restricted-syntax: off
no-spaced-func: off
no-tabs: off
no-ternary: off
no-trailing-spaces: off
no-underscore-dangle: off
no-unneeded-ternary: off
object-curly-newline: off
object-curly-spacing: off
object-property-newline: off
one-var-declaration-per-line: off
one-var: off
operator-assignment: off
operator-linebreak: off
padded-blocks: off
quote-props: off
quotes: off
require-jsdoc: off
semi-spacing: off
semi: off
sort-keys: off
sort-vars: off
space-before-blocks: off
space-before-function-paren: off
space-in-parens: off
space-infix-ops: off
space-unary-ops: off
spaced-comment: off
template-tag-spacing: off
unicode-bom: off
wrap-regex: off
# ECMAScript 6
arrow-body-style: off
arrow-parens: off
arrow-spacing: off
constructor-super: off
generator-star-spacing: off
no-class-assign: off
no-confusing-arrow: off
no-const-assign: off
no-dupe-class-members: off
no-duplicate-imports: off
no-new-symbol: off
no-restricted-imports: off
no-this-before-super: off
no-useless-computed-key: off
no-useless-constructor: off
no-useless-rename: off
no-var: off
object-shorthand: off
prefer-arrow-callback: off
prefer-const: off
prefer-destructuring: off
prefer-numeric-literals: off
prefer-rest-params: off
prefer-reflect: off
prefer-spread: off
prefer-template: off
require-yield: off
rest-spread-spacing: off
sort-imports: off
symbol-description: off
template-curly-spacing: off
yield-star-spacing: off
......@@ -50,6 +50,15 @@ JS & CSS Lint:
except:
- tags
codeclimate:
stage: test
tags:
- docker
script:
- make codeclimate
except:
- tags
Documentation:
stage: test
script:
......
[pycodestyle]
max-line-length = 120
[pep8]
max-line-length = 120
[pycodestyle]
max-line-length = 120
[pep8]
max-line-length = 120
......@@ -42,6 +42,10 @@ tests: test-build
@docker run --rm -t pyrmin:tests pep8
@docker run --rm -t pyrmin:tests grunt
codeclimate:
@docker run --rm --env CODE_PATH="$(shell pwd)" --volume "$(shell pwd)":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate validate-config
@docker run --rm --env CODE_PATH="$(shell pwd)" --volume "$(shell pwd)":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate analyze
docenv: auto-proxy
@python3 -m venv env
@$(ENV)/pip install -Ur docs/requirements.txt
......
......@@ -17,7 +17,23 @@ from .tools import *
from .plugins import Plugins
from .user import User
from ._core import Core
from ._core import __run_web_server
from ._core import Web
def parseconfigpath(opts):
config_path = "/etc/pyrmin/"
auto_upgrade = False
myopts, args = getopt.getopt(
opts,
"c:hv",
["help", "config", "verbose", "debug", "upgrade", "version"]
)
for o, a in myopts:
if o in ["-c", "--config"]:
config_path = a
if o in ["--upgrade"]:
auto_upgrade = True
return config_path, auto_upgrade
def returnparser(args_params=[]):
......@@ -52,18 +68,7 @@ def returnparser(args_params=[]):
if not args_params:
return parser
config_path = "/etc/pyrmin/"
auto_upgrade = False
myopts, args = getopt.getopt(
args_params[1:],
"c:hv",
["help", "config", "verbose", "debug", "upgrade", "version"]
)
for o, a in myopts:
if o in ["-c", "--config"]:
config_path = a
if o in ["--upgrade"]:
auto_upgrade = True
config_path, auto_upgrade = parseconfigpath(args_params[1:])
config = Core().get_conf(config_path)
......@@ -120,7 +125,7 @@ def main():
if "port" not in config['pyrmin']:
log.critical("No port defined")
sys.exit(1)
__run_web_server(config, __version__)
Web(config).run(__version__)
if __name__ == "__main__":
......
This diff is collapsed.
......@@ -35,7 +35,11 @@ class LogIn(object):
def login(self, username, password):
log.debug('user: ' + username)
if username == "admin":
if password == self.config['pyrmin']['password']:
if(
'pyrmin' in self.config and
'password' in self.config['pyrmin'] and
password == self.config['pyrmin']['password']
):
cherrypy.session['user'] = {
"username": username,
"auth": True,
......
This diff is collapsed.
{"version":3,"sources":["../../src/js/settings.js"],"names":["callback_store_list","data","$","html","css","each","plugins","plugin","append","attr","url","text","name","tags","i","this","toLowerCase","parseInt","replace","removeClass","addClass","document","ready","pyrmin","add_vendor","on","event","button","relatedTarget","namespace","modal","find","empty","config","load_data","nunjucks","render","err","res","fileinput","allowedFileExtensions","select2","click","formData","FormData","mode","val","get","files","length","prop","ajax","type","cache","contentType","processData","success","status","swal","error","console","log","title","showCancelButton","confirmButtonColor","confirmButtonText","cancelButtonText","closeOnConfirm","closeOnCancel","isConfirm","change","toggle","checked","iCheck","radioClass","token","get_data"],"mappings":";AAgJA,QAASA,qBAAoBC,GACzBC,EAAE,mBAAmBC,KAAK,qBAC1BD,EAAE,mBAAmBE,IAAI,UAAW,SACpCF,EAAEG,KAAKJ,EAAKK,QAAS,SAASC,GAC1BL,EAAE,mBACGM,OAAON,EAAE,qBACTO,KAAK,QAAQR,EAAKK,QAAQC,GAAQG,IAAM,8BACxCC,KAAKV,EAAKK,QAAQC,GAAQK,KAAO,IAAMX,EAAKK,QAAQC,GAAQM,KAAK,GAAGD,OAEzEV,EAAE,sBAAsBG,KAAK,SAASS,GAClC,GAAGZ,EAAEa,MAAMN,KAAK,kBAAkBO,gBAAkBf,EAAKK,QAAQC,GAAQK,KAAKI,cAO1E,MANGC,UAAShB,EAAKK,QAAQC,GAAQM,KAAK,GAAGD,KAAKM,QAAQ,MAAO,KAAOD,SAASf,EAAEa,MAAMN,KAAK,gBAAgBS,QAAQ,MAAO,KACrHhB,EAAE,QAAUA,EAAEa,MAAMN,KAAK,kBAAoB,0BAA0BU,YAAY,cAAcC,SAAS,gBAG1GlB,EAAE,QAAUA,EAAEa,MAAMN,KAAK,kBAAoB,0BAA0BU,YAAY,cAAcC,SAAS,kBAEvG,MAjKvBlB,EAAEmB,UAAUC,MAAM,WAEdC,SAASC,YAAY,OAAQ,UAAW,WAAY,YAAa,UAAW,WAG5EtB,EAAE,mBAAmBuB,GAAG,gBAAiB,SAAUC,GACjD,GAAIC,GAASzB,EAAEwB,EAAME,eACjBhB,EAAOe,EAAO1B,KAAK,QACnB4B,EAAYF,EAAO1B,KAAK,aAGxB6B,EAAQ5B,EAAEa,KACde,GAAMC,KAAK,gBAAgBpB,KAAKC,GAChCkB,EAAMC,KAAK,eAAeC,Q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CiE,EAAO3E,uBAM1E4E,SAASrD,SAASb,IAAM,0BAA2BV","file":"settings.min.js"}
\ No newline at end of file
{"version":3,"sources":["../../../src/js/settings.js"],"names":["callback_store_list","data","$","html","css","each","plugins","plugin","append","attr","url","text","name","tags","i","this","toLowerCase","labelclass","parseInt","replace","removeClass","addClass","document","ready","pyrmin","add_vendor","on","event","button","relatedTarget","namespace","modal","find","empty","config","load_data","nunjucks","render","err","res","fileinput","allowedFileExtensions","select2","click","formData","FormData","mode","val","get","files","length","prop","ajax","type","cache","contentType","processData","success","status","swal","error","console","log","title","showCancelButton","confirmButtonColor","confirmButtonText","cancelButtonText","closeOnConfirm","closeOnCancel","isConfirm","change","toggle","checked","iCheck","radioClass","token","get_data"],"mappings":";AAkJA,QAASA,qBAAoBC,GACzBC,EAAE,mBAAmBC,KAAK,qBAC1BD,EAAE,mBAAmBE,IAAI,UAAW,SACpCF,EAAEG,KAAKJ,EAAKK,QAAS,SAASC,GAC1BL,EAAE,mBACGM,OAAON,EAAE,qBACTO,KAAK,QAAQR,EAAKK,QAAQC,GAAQG,IAAM,8BACxCC,KAAKV,EAAKK,QAAQC,GAAQK,KAAO,IAAMX,EAAKK,QAAQC,GAAQM,KAAK,GAAGD,OAEzEV,EAAE,sBAAsBG,KAAK,SAASS,GAClC,GAAGZ,EAAEa,MAAMN,KAAK,kBAAkBO,gBAAkBf,EAAKK,QAAQC,GAAQK,KAAKI,cAAe,CACzF,GAAIC,GAAcC,SAASjB,EAAKK,QAAQC,GAAQM,KAAK,GAAGD,KAAKO,QAAQ,MAAO,IAAK,IAAMD,SAAShB,EAAEa,MAAMN,KAAK,gBAAgBU,QAAQ,MAAO,IAAK,IAAO,eAAiB,eAEzK,OADAjB,GAAE,QAAUA,EAAEa,MAAMN,KAAK,kBAAoB,0BAA0BW,YAAY,cAAcC,SAASJ,IACnG,OA7JvBf,EAAEoB,UAAUC,MAAM,WAEdC,SAASC,YAAY,OAAQ,UAAW,WAAY,YAAa,UAAW,WAG5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AE,kBAAkBsE,OAAOzD,KAAK0D,WAC/BF,SAEHrE,EAAE,WAAWwE,QACXC,WAAY,qBAIdzE,EAAE,cAAcyC,MAAM,WAClB,GAAIiC,GAAQ1E,EAAE,gBAAgB6C,KAC9B,OAAa,KAAV6B,MACC1E,GAAE,wBAAwBmB,SAAS,iBAInCwD,UAASrD,SAASd,IAAM,iCAAmCkE,EAAO5E,uBAM1E6E,SAASrD,SAASd,IAAM,0BAA2BV","file":"settings.min.js"}
\ No newline at end of file
......@@ -27,6 +27,19 @@ class User():
def __init__(self, config):
self.config = config
self.__set_guest_user()
self.__set_cli_user()
self.__set_auth_module_user()
if hasattr(cherrypy, 'session') and 'user' in cherrypy.session and cherrypy.session['user'] is not None:
log.debug(cherrypy.session['user'])
self.username = cherrypy.session['user']['username']
self.auth = cherrypy.session['user']['auth']
self.admin = cherrypy.session['user']['admin']
self.displayname = cherrypy.session['user']['displayname']
self.img = cherrypy.session['user']['img']
def __set_guest_user(self):
self.username = "Guest"
self.auth = False
self.admin = False
......@@ -36,38 +49,30 @@ class User():
else:
self.img = "https://pyrmin.io/img/default-user.png"
def __set_cli_user(self):
if not hasattr(cherrypy, 'session'):
self.username = getpass.getuser()
self.displayname = self.username + "@" + socket.gethostname()
def __set_auth_module_user(self):
if (
not self.header_auth() and
hasattr(cherrypy, 'session') and
'user' not in cherrypy.session and
'pyrmin' in self.config and
'auth_module' in self.config['pyrmin'] and
self.config['pyrmin']['auth_module'] in Core(self.config).get_conf(self.config['pyrmin']['config_path'])
self.config['pyrmin']['auth_module'] in Core(self.config).get_conf(self.config['pyrmin']['config_path']) and
'Remote-User' in cherrypy.request.headers
):
log.debug("Auth mod: " + self.config['pyrmin']['auth_module'] + " enabled !")
log.debug(cherrypy.request.headers)
if 'Remote-User' in cherrypy.request.headers:
name = cherrypy.request.headers['Remote-User']
log.debug("Remote-User: " + name)
pname = self.config['pyrmin']['auth_module']
if Plugins(config).get(pname):
external_user = Plugins(config).get(pname).auth(
Core(self.config).get_conf(self.config['pyrmin']['config_path'])[pname]
).get(name)
cherrypy.session['user'] = external_user
Core(self.config).build_menu()
if hasattr(cherrypy, 'session') and 'user' in cherrypy.session and cherrypy.session['user'] is not None:
log.debug(cherrypy.session['user'])
self.username = cherrypy.session['user']['username']
self.auth = cherrypy.session['user']['auth']
self.admin = cherrypy.session['user']['admin']
self.displayname = cherrypy.session['user']['displayname']
self.img = cherrypy.session['user']['img']
name = cherrypy.request.headers['Remote-User']
log.debug("Remote-User: " + name)
pname = self.config['pyrmin']['auth_module']
if Plugins(self.config).get(pname):
external_user = Plugins(self.config).get(pname).auth(
Core(self.config).get_conf(self.config['pyrmin']['config_path'])[pname]
).get(name)
cherrypy.session['user'] = external_user
Core(self.config).build_menu()
def getUserAuthorization(self):
try:
......
......@@ -12,11 +12,14 @@ packages = [
'pyrmin.core'
]
with io.open(os.path.join(here, 'requirements.txt'), encoding='utf-8') as f:
require = f.readlines()
with io.open(os.path.join(here, 'requirements-tests.txt'), encoding='utf-8') as f:
tests_require = f.readlines()
def read_file(name):
with io.open(os.path.join(here, name), encoding='utf-8') as r:
return r.readlines()
require = read_file('requirements.txt')
tests_require = read_file('requirements-tests.txt')
buf = []
for filename in ['README.md', 'CHANGELOG.md']:
......
This diff is collapsed.
/*eslint complexity: ["error", 10]*/
$(document).ready(function() {
pyrmin().add_vendor(['swal', 'select2', 'nunjucks', 'fileinput', 'chartjs', 'icheck']);
......@@ -153,12 +155,8 @@ function callback_store_list(data) {
$('ul#plugins_list li').each(function(i) {
if($(this).attr('data-namespace').toLowerCase() === data.plugins[plugin].name.toLowerCase()) {
if(parseInt(data.plugins[plugin].tags[0].name.replace(/\./g, '')) > parseInt($(this).attr('data-version').replace(/\./g, ''))) {
$('#row_' + $(this).attr('data-namespace') + ' .label-plugin-version').removeClass("label-info").addClass("label-danger");
}
else {
$('#row_' + $(this).attr('data-namespace') + ' .label-plugin-version').removeClass("label-info").addClass("label-success");
}
var labelclass = (parseInt(data.plugins[plugin].tags[0].name.replace(/\./g, ''), 10) > parseInt($(this).attr('data-version').replace(/\./g, ''), 10)) ? 'label-danger' : 'label-success';
$('#row_' + $(this).attr('data-namespace') + ' .label-plugin-version').removeClass("label-info").addClass(labelclass);
return false;
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment