Skip to content

Commit

Permalink
update script and prepare for submission
Browse files Browse the repository at this point in the history
  • Loading branch information
mlinsins committed Feb 2, 2023
1 parent 6252c1c commit 2600ce6
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions buildserver_log.py → transparencylog.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,40 @@
"""
Copyright (c) 2022 Mario Lins <mario.lins@ins.jku.at>
Copyright (c) 2023 Mario Lins <mario.lins@ins.jku.at>
Licensed under the EUPL, Version 1.2.
You may obtain a copy of the Licence at:
https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
"""
#!/usr/bin/env python3

import collections
import defusedxml.minidom
import git
import glob
import hashlib
import os
import json
import logging
import requests
import shutil
import tempfile
import zipfile
from argparse import ArgumentParser

from . import _
from . import common
from . import deploy
from .exception import FDroidException


def main():
global options

parser = ArgumentParser()
common.setup_global_opts(parser)
parser.add_argument("--personalityaddress",
default="http://IP_REST_API:PORT/",
default="https://ENTER_DEFAULT_IP:PORT/",
help=_("Path to the the REST API of the personality"))
parser.add_argument("--appid",
default="com.company.appid",
Expand All @@ -22,7 +43,7 @@ def main():
default="1",
help=_("App Version"))
parser.add_argument("--treeid",
default="5253222656226122581",
default="ENTER_DEFAULT_TREE_ID",
help=_("Tree ID"))
options = parser.parse_args()

Expand All @@ -33,10 +54,19 @@ def main():
for blk in iter(lambda: f.read(4096),b""):
sha256_hash.update(blk)
print(sha256_hash.hexdigest())

createlogurl = options.personalityaddress + 'Log/AddLogEntry?treeId=' +options.treeid
logentry = {"applicationId":options.appid,"version":options.version,"signatureData":sha256_hash.hexdigest()}
response = requests.post(createlogurl,json=logentry)

createloginurl = options.personalityaddress + 'Login/Login'
logincredentials = {"username": "buildserver", "password":"ENTER_PASSWORD"}
loginresponse = requests.post(createloginurl,json=logincredentials,verify='PATH_TO_CERTIFICATE')
#print(loginresponse.json())
token = loginresponse.json()['token']
print(token)

response = requests.post(createlogurl,headers={'Authorization': 'Bearer '+token},json=logentry,verify='PATH_TO_CERTIFICATE')
print(response)
print(response.json())
print(response.status_code)
print(createlogurl)
Expand Down

0 comments on commit 2600ce6

Please sign in to comment.