Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
envsetup
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mediaserver
envsetup
Commits
e63c1a52
Commit
e63c1a52
authored
6 years ago
by
Florent Thiery
Browse files
Options
Downloads
Patches
Plain Diff
add media deployment envsetup task for demokit, refs
#26844
parent
42e41733
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
5.MediaServer/3.Deploy_demokit/0_setup.py
+22
-0
22 additions, 0 deletions
5.MediaServer/3.Deploy_demokit/0_setup.py
5.MediaServer/3.Deploy_demokit/publish_zip_by_url.py
+74
-0
74 additions, 0 deletions
5.MediaServer/3.Deploy_demokit/publish_zip_by_url.py
with
96 additions
and
0 deletions
5.MediaServer/3.Deploy_demokit/0_setup.py
0 → 100644
+
22
−
0
View file @
e63c1a52
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import
utils
CONTENT
=
[
"
https://www.ubicast.eu/media/downloads/TradeshowDemoKit/medical_education.zip
"
,
"
https://www.ubicast.eu/media/downloads/TradeshowDemoKit/rich-media-sneak-peek.zip
"
]
def
setup
(
interactive
=
True
):
cmds
=
list
()
options
=
{
"
ms_url
"
:
utils
.
get_conf
(
'
MS_SERVER_NAME
'
),
"
ms_apikey
"
:
utils
.
get_conf
(
'
MS_API_KEY
'
)
}
cmd_template
=
"
./publish_zip_by_url.py -w {ms_url} -u %s -a {ms_apikey}
"
.
format
(
**
options
)
for
c
in
CONTENT
:
cmd
=
cmd_template
%
c
cmds
.
append
(
cmd
)
utils
.
run_commands
(
cmds
)
This diff is collapsed.
Click to expand it.
5.MediaServer/3.Deploy_demokit/publish_zip_by_url.py
0 → 100755
+
74
−
0
View file @
e63c1a52
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2017, Florent Thiery, Stéphane Diemer
import
argparse
import
logging
import
os
import
requests
import
imp
logger
=
logging
.
getLogger
(
'
mediaserver_client
'
)
MiB
=
1024
*
1024
session
=
None
MS_CLIENT_URL
=
'
https://raw.githubusercontent.com/UbiCastTeam/mediaserver-client/master/mediaserver_api_client.py
'
MS_CLIENT_PATH
=
'
/tmp/mediaserver_api_client.py
'
def
get_client_module
():
# download and load client script
if
os
.
path
.
exists
(
MS_CLIENT_PATH
):
logger
.
info
(
'
MediaServer client is already downloaded:
"
%s
"
.
'
,
MS_CLIENT_PATH
)
else
:
req
=
requests
.
get
(
MS_CLIENT_URL
,
timeout
=
10
)
if
not
req
.
ok
:
raise
Exception
(
'
Failed to download MS client. Status: %s, response: %s
'
%
(
req
.
status_code
,
req
.
text
))
with
open
(
MS_CLIENT_PATH
,
'
w
'
)
as
fo
:
fo
.
write
(
req
.
text
)
logger
.
info
(
'
MediaServer client downloaded:
"
%s
"
.
'
,
MS_CLIENT_PATH
)
ms_client
=
imp
.
load_source
(
'
ms_client
'
,
MS_CLIENT_PATH
)
return
ms_client
if
__name__
==
'
__main__
'
:
log_format
=
'
%(asctime)s %(name)s %(levelname)s %(message)s
'
logging
.
basicConfig
(
level
=
logging
.
DEBUG
,
format
=
log_format
)
urllib3_logger
=
logging
.
getLogger
(
'
requests.packages.urllib3
'
)
urllib3_logger
.
setLevel
(
logging
.
WARNING
)
parser
=
argparse
.
ArgumentParser
(
description
=
'
Import media from a zip archive into a portal on the commandline
'
)
parser
.
add_argument
(
'
-w
'
,
'
--webtv
'
,
required
=
True
,
help
=
'
webtv url
'
)
parser
.
add_argument
(
'
-u
'
,
'
--url
'
,
required
=
True
,
help
=
'
media zip url
'
)
parser
.
add_argument
(
'
-a
'
,
'
--apikey
'
,
required
=
True
,
help
=
'
apikey
'
)
args
=
parser
.
parse_args
()
CONFIG
=
{
'
SERVER_URL
'
:
args
.
webtv
,
'
API_KEY
'
:
args
.
apikey
,
'
PROXIES
'
:
{
'
http
'
:
''
,
'
https
'
:
''
},
'
UPLOAD_CHUNK_SIZE
'
:
5
*
MiB
,
'
VERIFY_SSL
'
:
False
,
'
CLIENT_ID
'
:
'
python-api-client
'
,
}
mscli
=
get_client_module
()
msc
=
mscli
.
MediaServerClient
()
msc
.
config
=
CONFIG
# ping
print
(
msc
.
api
(
'
/
'
,
method
=
'
get
'
))
with
open
(
'
/tmp/file.zip
'
,
'
wb
'
)
as
f
:
f
.
write
(
requests
.
get
(
args
.
url
).
content
)
# add media with a zip
#print(msc.add_media('Test multichunk upload zip', file_path='/tmp/file.zip'))
print
(
msc
.
add_media
(
file_path
=
'
/tmp/file.zip
'
))
# add user
# print(msc.api('users/add/', method='post', data={'email': 'test@test.com'}))
# add users with csv file; example file (header should be included):
# Firstname;Lastname;Email;Company
# Albert;Einstein;albert.einstein@test.com;Humanity
# msc.import_users_csv('users.csv')
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment