Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
joker
/
wiki
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
2e0a0fd5
authored
Jul 09, 2021
by
Karsa Zoltán István
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
script linux ok
parent
47a4c5a7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
0 deletions
+75
-0
upgrade/upgrade.py
+75
-0
No files found.
upgrade/upgrade.py
0 → 100644
View file @
2e0a0fd5
from
subprocess
import
Popen
,
PIPE
import
requests
import
socket
import
requests.packages.urllib3.util.connection
as
urllib3_cn
def
allowed_gai_family
():
family
=
socket
.
AF_INET
# force IPv4
return
family
urllib3_cn
.
allowed_gai_family
=
allowed_gai_family
ANACONDA
=
'4.10.3'
FILES
=
{
'__init__.py'
:
[
'https://git.ik.bme.hu/joker/joker/raw/script/upgrade/files/__init__.py'
,
'lib/python3.8/site-packages/slurm_jupyter/'
],
}
def
anaconda
():
with
Popen
(
'conda --version'
,
stdout
=
PIPE
,
stderr
=
PIPE
,
shell
=
True
)
as
proc
:
(
outdata
,
errdata
)
=
proc
.
communicate
()
if
errdata
.
decode
(
'UTF-8'
)
!=
''
:
return
False
ver
=
outdata
.
decode
(
'UTF-8'
)
.
split
()
print
(
f
'
\t
Jelenlegi verzió: {ver[1]}'
)
print
(
f
'
\t
Ajánlott verzió: {ANACONDA}'
)
return
ver
[
1
]
==
ANACONDA
def
path
():
with
Popen
(
'conda info'
,
stdout
=
PIPE
,
stderr
=
PIPE
,
shell
=
True
)
as
proc
:
(
outdata
,
errdata
)
=
proc
.
communicate
()
if
errdata
.
decode
(
'UTF-8'
)
!=
''
:
return
False
,
''
path
=
outdata
.
decode
(
'UTF-8'
)
.
split
(
"
\n
"
)[
2
]
path
=
path
.
split
(
":"
)[
1
]
.
split
()[
0
]
return
True
,
path
def
getFile
(
dir
,
name
):
print
(
f
'
\t
Letöltés: {FILES[name][0]}'
)
print
(
f
'
\t
A fájl ide kerül: {dir}/{name}'
)
headers
=
{
"User-Agent"
:
"Mozilla/5.0 (X11; CrOS x86_64 12871.102.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36"
}
req
=
requests
.
get
(
FILES
[
name
][
0
],
stream
=
True
,
headers
=
headers
)
print
(
'
\t
'
,
end
=
" "
)
with
open
(
f
'{dir}/{FILES[name][1]}{name}'
,
'wb'
)
as
f
:
for
chunk
in
req
.
iter_content
(
chunk_size
=
256
):
if
chunk
:
f
.
write
(
chunk
)
print
(
'.'
,
end
=
" "
)
print
(
'
\n\t
OK
\n
'
)
def
files
(
dir
):
print
(
'Fájlok letöltése'
)
getFile
(
dir
,
'__init__.py'
)
def
upgrade
():
print
(
'Anaconda könyvtár keresése'
)
ok
,
dir
=
path
()
if
ok
:
print
(
f
'
\t
Kiolvasott útvonal: {dir}'
)
else
:
print
(
'
\t
Nem tudtam útvonalat kiolvasni, adja meg: '
)
dir
=
input
()
print
(
'Megpróbálom ezzel ...'
)
files
(
dir
)
if
__name__
==
'__main__'
:
print
(
"Anaconda vizsgálata ..."
)
if
anaconda
():
print
(
'OK
\n
'
)
upgrade
()
else
:
print
(
'Valami baj lehet! Folytatja (i/n) ?'
)
ok
=
input
()
if
ok
==
'i'
or
ok
==
'I'
:
upgrade
()
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