Skip to content
This repository was archived by the owner on May 30, 2023. It is now read-only.

Commit 054561a

Browse files
authored
Merge pull request #12 from daita-technologies/develop
✨ Release 0.0.7 `daita-python-library`
2 parents a787c45 + e5af9ba commit 054561a

14 files changed

Lines changed: 230 additions & 63 deletions

.github/workflows/build.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@ jobs:
3131
build
3232
--user
3333
34+
- name: Make .env file
35+
uses: SpicyPizza/create-envfile@v1.3
36+
with:
37+
envkey_DAITA_TOKEN: ${{ secrets.DAITA_TOKEN }}
38+
envkey_PRESIGNED_URL: ${{ secrets.PRESIGNED_URL }}
39+
envkey_CHECK_FILE_EXISTENCE: ${{ secrets.CHECK_FILE_EXISTENCE }}
40+
envkey_CREATE_PRESIGNED_SINGLE_URL: ${{ secrets.CREATE_PRESIGNED_SINGLE_URL }}
41+
envkey_UPLOAD_COMPRESSED_FILE: ${{ secrets.UPLOAD_COMPRESSED_FILE }}
42+
envkey_UPLOAD_TASK_PROGRESS: ${{ secrets.TASK_PROGRESS }}
43+
envkey_UPLOAD_UPDATE: ${{secrets.UPLOAD_UPDATE}}
44+
directory: ./daita
45+
file_name: .env
46+
fail_on_empty: true
47+
3448
- name: Build a binary wheel and a source tarball
3549
run: >-
3650
python -m

.github/workflows/publish-pypi.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,20 @@ jobs:
3333
build
3434
--user
3535
36+
- name: Make .env file
37+
uses: SpicyPizza/create-envfile@v1.3
38+
with:
39+
envkey_DAITA_TOKEN: ${{ secrets.DAITA_TOKEN }}
40+
envkey_PRESIGNED_URL: ${{ secrets.PRESIGNED_URL }}
41+
envkey_CHECK_FILE_EXISTENCE: ${{ secrets.CHECK_FILE_EXISTENCE }}
42+
envkey_CREATE_PRESIGNED_SINGLE_URL: ${{ secrets.CREATE_PRESIGNED_SINGLE_URL }}
43+
envkey_UPLOAD_COMPRESSED_FILE: ${{ secrets.UPLOAD_COMPRESSED_FILE }}
44+
envkey_UPLOAD_TASK_PROGRESS: ${{ secrets.TASK_PROGRESS }}
45+
envkey_UPLOAD_UPDATE: ${{secrets.UPLOAD_UPDATE}}
46+
directory: ./daita
47+
file_name: .env
48+
fail_on_empty: true
49+
3650
- name: Build a binary wheel and a source tarball
3751
run: >-
3852
python -m

.github/workflows/publish-test-pypi.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@ jobs:
3434
build
3535
--user
3636
37+
- name: Make .env file
38+
uses: SpicyPizza/create-envfile@v1.3
39+
with:
40+
envkey_DAITA_TOKEN: ${{ secrets.DAITA_TOKEN }}
41+
envkey_PRESIGNED_URL: ${{ secrets.PRESIGNED_URL }}
42+
envkey_CHECK_FILE_EXISTENCE: ${{ secrets.CHECK_FILE_EXISTENCE }}
43+
envkey_CREATE_PRESIGNED_SINGLE_URL: ${{ secrets.CREATE_PRESIGNED_SINGLE_URL }}
44+
envkey_UPLOAD_COMPRESSED_FILE: ${{ secrets.UPLOAD_COMPRESSED_FILE }}
45+
envkey_UPLOAD_TASK_PROGRESS: ${{ secrets.TASK_PROGRESS }}
46+
envkey_UPLOAD_UPDATE: ${{secrets.UPLOAD_UPDATE}}
47+
directory: ./daita
48+
file_name: .env
49+
fail_on_empty: true
50+
3751
- name: Build a binary wheel and a source tarball
3852
run: >-
3953
python -m

.gitignore

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ share/python-wheels/
2828
MANIFEST
2929

3030
# PyInstaller
31-
# Usually these files are written by a python script from a template
32-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
3333
*.manifest
3434
*.spec
3535
pip-log.txt
@@ -83,10 +83,10 @@ ipython_config.py
8383
.python-version
8484

8585
# pipenv
86-
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
87-
# However, in case of collaboration, if having platform-specific dependencies or dependencies
88-
# having no cross-platform support, pipenv may install dependencies that don't work, or not
89-
# install all needed dependencies.
86+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
87+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
88+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
89+
# install all needed dependencies.
9090
#Pipfile.lock
9191

9292
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
@@ -101,6 +101,7 @@ celerybeat.pid
101101

102102
# Environments
103103
.env
104+
.env.development
104105
.venv
105106
env/
106107
venv/

CHANGELOG.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
76

8-
## `0.0.6`29-10-2022
7+
## `0.0.7`22-11-2022
98

109
### Fixed
1110

12-
- Fixed [`Unicode decode error`](https://github.com/daita-technologies/daita-python-library/issues/3).
11+
- Fixed [`Remove .env.development file`](https://github.com/daita-technologies/daita-python-library/issues/5). ([#8](https://github.com/daita-technologies/daita-python-library/pull/8))
12+
13+
### Added
14+
15+
- Added [`Handling of unexpected interruptions during upload`](https://github.com/daita-technologies/daita-python-library/issues/6). ([#10](https://github.com/daita-technologies/daita-python-library/pull/10))
16+
- Added [`Show progress bar for uploads`](https://github.com/daita-technologies/daita-python-library/issues/4). ([#11](https://github.com/daita-technologies/daita-python-library/pull/11))
17+
18+
## `0.0.6` – 29-10-2022
19+
20+
### Fixed
1321

22+
- Fixed [`Unicode decode error`](https://github.com/daita-technologies/daita-python-library/issues/3). ([#7](https://github.com/daita-technologies/daita-python-library/pull/7))

daita/.env.development

Lines changed: 0 additions & 5 deletions
This file was deleted.

daita/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.0.6"
1+
__version__ = "0.0.7"

daita/daita.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
from daita.dashboard import dashboard
21
import argparse
2+
from daita.utils import exception_handler
3+
from daita.dashboard import dashboard
4+
from daita.footer import footer
35

4-
5-
parser = argparse.ArgumentParser(description="Optional app description")
6-
parser.add_argument("--dir", type=str, help="A required integer positional argument")
6+
parser = argparse.ArgumentParser(
7+
description="Upload images via DAITA's official easy-to-use Python library."
8+
)
9+
parser.add_argument("--dir", type=str, help="The root directory path for the images.")
710
parser.add_argument(
8-
"--daita_token", type=str, help="A required integer positional argument"
11+
"--daita_token", type=str, help="User access token for the DAITA platform."
912
)
1013
args = parser.parse_args()
1114
dir = args.dir
1215
daita_token = args.daita_token
1316

1417

18+
@exception_handler
1519
def main():
1620
dashboard(daita_token=daita_token, dir=dir)
17-
pass

daita/dashboard.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
import glob
32
import requests
43
import time
54
from os import system, name
@@ -21,7 +20,7 @@ def validCompressfile(filename):
2120

2221
def listImageFile(dir):
2322
filenames = []
24-
for root, subFolder, files in os.walk(dir):
23+
for root, files in os.walk(dir):
2524
for item in files:
2625
if validFileImage(item):
2726
filenames.append(os.path.join(root, item))
@@ -42,8 +41,7 @@ def checkDaitaToken(daita_token):
4241
response = requests.get(checkDaitaTokenEndpoint, params=params)
4342
data = response.json()
4443
if data["error"] == True:
45-
print(data["message"])
46-
os._exit(1)
44+
Exception("Failed checkDaitaToken: {}".format(data["message"]))
4745

4846

4947
def listAllFilesInDirectory(dir):
@@ -106,12 +104,16 @@ def dashboard(daita_token, dir):
106104

107105
# check input directory
108106
if not os.path.isdir(dir):
107+
path = dir
108+
if validCompressfile(path):
109+
dashboardCompressFiles([path], daita_token)
109110
print("Please input your directory path; try it again!")
110111
footer()
112+
111113
imagefiles, compressfiles = listAllFilesInDirectory(dir)
112114

113115
if len(imagefiles) == 0 and len(compressfiles) == 0:
114-
print("Folder is empty; please select again!")
116+
print("Folder is empty, please select again!")
115117
footer()
116118

117119
if len(imagefiles) > 0 and len(compressfiles) == 0:

daita/load_env.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import os
12
from dotenv import load_dotenv
23
from pathlib import Path
3-
import os
4+
45

56
pwd = os.path.dirname(os.path.abspath(__file__))
6-
envfile = os.path.join(pwd, ".env.development")
7+
envfile = os.path.join(pwd, ".env")
78
dotenv_path = Path(envfile)
89
load_dotenv(dotenv_path=dotenv_path)

0 commit comments

Comments
 (0)