Skip to content

Commit

Permalink
Merge pull request #814 from Johaney-s/webcentrum
Browse files Browse the repository at this point in the history
feat(webcentrum_eosc): new configurable service
  • Loading branch information
Johaney-s authored Sep 11, 2023
2 parents 4be6979 + bb268b0 commit df3ea68
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
12 changes: 12 additions & 0 deletions gen/webcentrum_eosc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/perl

use strict;
use warnings;
use File::Basename;
use perunDataGenerator;

local $::SERVICE_NAME = basename($0);
local $::PROTOCOL_VERSION = "3.0.0";
local $::SKIP_NON_VALID_MEMBERS = 1;

perunDataGenerator::generateMemberUsersDataInJson;
1 change: 1 addition & 0 deletions send/umbraco_mu
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ send_lib.check_destination_format(destination, destination_type)

auth = send_lib.get_auth_credentials(SERVICE_NAME, destination)

send_lib.create_lock(SERVICE_NAME, destination)
gen_folder = send_lib.get_gen_folder(facility, SERVICE_NAME)
with send_lib.prepare_temporary_directory() as temp_dir:
send_lib.copy_files_to_directory(gen_folder, temp_dir)
Expand Down
34 changes: 34 additions & 0 deletions send/webcentrum_eosc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python3
import sys
import requests
import send_lib
import tarfile

SERVICE_NAME = "webcentrum_eosc"
TIMEOUT = 1800 # 30 * 60 sec = 30 min

send_lib.check_input_fields(sys.argv, True)

facility = sys.argv[1]
destination = sys.argv[2]
destination_type = sys.argv[3]

send_lib.check_destination_type_allowed(destination_type, send_lib.DESTINATION_TYPE_URL)
send_lib.check_destination_format(destination, destination_type)

auth = send_lib.get_auth_credentials(SERVICE_NAME, destination)

send_lib.create_lock(SERVICE_NAME, destination)
gen_folder = send_lib.get_gen_folder(facility, SERVICE_NAME)
with send_lib.prepare_temporary_directory() as temp_dir:
send_lib.copy_files_to_directory(gen_folder, temp_dir)

with tarfile.open(temp_dir + '/perun_data.tar.gz', 'w:gz', format=tarfile.GNU_FORMAT) as archive:
archive.add(temp_dir, arcname='.')

with open(temp_dir + '/perun_data.tar.gz', 'rb') as compressed:
headers = {'Content-type': 'application/tar+gzip'}
response = requests.put(destination, headers=headers, data=compressed, auth=auth, timeout=TIMEOUT)
if not response.ok:
send_lib.die_with_error(
"Request ended with error code: " + str(response.status_code))

0 comments on commit df3ea68

Please sign in to comment.