File: upload.py

package info (click to toggle)
azure-cli 2.82.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,359,416 kB
  • sloc: python: 1,910,381; sh: 1,343; makefile: 406; cs: 145; javascript: 74; sql: 37; xml: 21
file content (38 lines) | stat: -rw-r--r-- 1,302 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

import sys
import os
import datetime

ARTIFACT_DIR = sys.argv[1]
ACCOUNT_KEY = sys.argv[2] # not used
USER_LIVE = sys.argv[3]


def main():
    # Create container
    date = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
    if USER_LIVE == '--live':
        mode = 'live'
    elif USER_LIVE == '':
        mode = 'replay'
    else:
        mode = ''
    container = date + mode
    cmd = 'az storage container create -n {} --account-name clitestresultstac --public-access container --auth-mode login'
    os.popen(cmd.format(container))

    # Upload files
    for root, dirs, files in os.walk(ARTIFACT_DIR):
        for name in files:
            if name.endswith('html') or name.endswith('json'):
                fullpath = os.path.join(root, name)
                cmd = 'az storage blob upload -f {} -c {} -n {} --account-name clitestresultstac'
                os.popen(cmd.format(fullpath, container, name))


if __name__ == '__main__':
    main()