Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
w2pext
plugin_dbui
Commits
93aaa20b
Commit
93aaa20b
authored
Dec 01, 2019
by
LE GAC Renaud
Browse files
Update helper to improve get_version.
parent
7dea306f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
50 deletions
+26
-50
modules/plugin_dbui/helper.py
modules/plugin_dbui/helper.py
+26
-50
No files found.
modules/plugin_dbui/helper.py
View file @
93aaa20b
...
...
@@ -20,6 +20,8 @@ from gluon.validators import (IS_DATE_IN_RANGE,
IS_INT_IN_RANGE
,
IS_MATCH
,
IS_LENGTH
)
from
pathlib
import
Path
GIT
=
"/usr/bin/git"
REX_REFERENCE
=
re
.
compile
(
"^reference (\w+)$"
)
...
...
@@ -605,64 +607,40 @@ def get_versions():
# plugin ace
ace
=
T
(
"not install"
)
path
=
opj
(
server_path
,
"static"
,
"plugin_ace"
)
if
ope
(
path
):
path
=
Path
(
server_path
,
"static"
,
"plugin_ace"
)
if
path
.
exists
(
):
ace
=
T
(
"install"
)
# plugin dbui
fn
=
opj
(
server_path
,
"static"
,
"plugin_dbui"
,
"src"
,
"Dbui.js"
)
with
open
(
fn
,
"r"
)
as
fi
:
s
=
fi
.
read
()
m
=
re
.
search
(
'(version: *")([\w\._-]*)(")'
,
s
)
dbui
=
m
.
group
(
2
)
path
=
Path
(
server_path
,
"static"
,
"plugin_dbui"
,
VERSION
)
if
path
.
exists
():
dbui
=
path
.
read_text
()
# plugin Ext JS
extjs
=
T
(
"not install"
)
path
=
opj
(
server_path
,
"static"
,
"plugin_extjs"
)
if
ope
(
path
):
fn
=
opj
(
path
,
"version.properties"
)
with
open
(
fn
,
"r"
)
as
fi
:
s
=
fi
.
read
()
m
=
re
.
search
(
r
"version.release=(\d+(\.\d+)*)"
,
s
)
if
m
:
extjs
=
m
.
group
(
1
)
path
=
Path
(
server_path
,
"static"
,
"plugin_extjs"
,
"version.properties"
)
if
path
.
exists
():
data
=
path
.
read_text
()
mtch
=
re
.
search
(
r
"version.release=(\d+(\.\d+)*)"
,
data
)
if
mtch
:
extjs
=
mtch
.
group
(
1
)
# plugin mathjax
mathjax
=
T
(
"not install"
)
path
=
opj
(
server_path
,
"static"
,
"plugin_mathjax"
)
if
ope
(
path
):
fn
=
opj
(
server_path
,
"static"
,
"plugin_mathjax"
,
"MathJax.js"
)
with
open
(
fn
,
"r"
)
as
fi
:
s
=
fi
.
read
()
m
=
re
.
search
(
r
'MathJax.version="(\d+(\.\d+)*)";'
,
s
)
if
m
:
mathjax
=
m
.
group
(
1
)
# other plugins
plugins
=
[]
stdplgs
=
(
"plugin_ace"
,
"plugin_dbui"
,
"plugin_extjs"
,
"plugin_mathjax"
)
for
plg
in
os
.
listdir
(
opj
(
server_path
,
"static"
)):
if
plg
.
startswith
(
"plugin"
)
and
plg
not
in
stdplgs
:
path
=
opj
(
server_path
,
"static"
,
plg
,
"VERSION"
)
if
opj
(
path
):
with
open
(
opj
(
path
))
as
fi
:
plugins
.
append
(
dict
(
code
=
plg
,
version
=
fi
.
read
()))
else
:
plugins
.
append
(
dict
(
code
=
plg
,
version
=
T
(
"install"
)))
path
=
Path
(
server_path
,
"static"
,
"plugin_mathjax"
,
"MathJax.js"
)
if
path
.
exists
():
data
=
path
.
read_text
()
mtch
=
re
.
search
(
r
'MathJax.version="(\d+(\.\d+)*)";'
,
data
)
if
mtch
:
mathjax
=
mtch
.
group
(
1
)
# web2py
web2py
=
""
val
=
current
.
request
.
env
.
web2py_version
if
isinstance
(
val
,
str
):
m
=
re
.
match
(
"\d+\.\d+\.\d+"
,
val
)
if
m
:
web2py
=
m
.
group
()
m
tch
=
re
.
match
(
"\d+\.\d+\.\d+"
,
val
)
if
m
tch
:
web2py
=
m
tch
.
group
()
elif
isinstance
(
val
,
(
tuple
,
list
)):
li
=
[
str
(
plg
)
for
plg
in
val
if
isinstance
(
plg
,
int
)]
...
...
@@ -670,12 +648,11 @@ def get_versions():
# version of the application
myapp
=
T
(
"unknown"
)
path
=
Path
(
server_path
,
VERSION
)
if
path
.
exists
():
myapp
=
path
.
read_text
()
if
ope
(
VERSION
):
with
open
(
opj
(
server_path
,
VERSION
))
as
fi
:
myapp
=
fi
.
read
()
elif
ope
(
GIT
):
elif
Path
(
GIT
).
exists
():
ref_path
=
os
.
getcwd
()
os
.
chdir
(
server_path
)
...
...
@@ -694,7 +671,6 @@ def get_versions():
dict
(
code
=
"pandas"
,
version
=
pnd
),
dict
(
code
=
current
.
request
.
application
,
version
=
myapp
)]
li
.
extend
(
plugins
)
li
.
sort
(
key
=
lambda
dct
:
dct
[
"code"
])
return
li
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment