diff --git a/app/pack.py b/app/pack.py index b81e4f2..c0119cd 100755 --- a/app/pack.py +++ b/app/pack.py @@ -17,12 +17,10 @@ class Pack: shutil.rmtree("files") os.mkdir("files") - - - # info = InMemoryAccountInfo() # store credentials, tokens and cache in memory - # self.b2_api = B2Api(info) - # self.b2_api.authorize_account("production", os.environ.get("B2_ID"), os.environ.get("B2_KEY")) - # self.bucket = self.b2_api.get_bucket_by_name(os.environ.get("BUCKET")) + info = InMemoryAccountInfo() # store credentials, tokens and cache in memory + self.b2_api = B2Api(info) + self.b2_api.authorize_account("production", os.environ.get("B2_ID"), os.environ.get("B2_KEY")) + self.bucket = self.b2_api.get_bucket_by_name(os.environ.get("BUCKET")) def clone(self): command = f"git clone -b {self.branch} --single-branch {self.packurl} files/resourcepack" @@ -33,11 +31,12 @@ class Pack: shutil.rmtree("files") def pull(self) -> None: - print(os.environ.get("GIT_SSH_COMMAND")) + print("Pulling") command = f"git -C files/resourcepack pull origin {self.branch}" return os.system(command) def collate(self) -> None: + print("Collating") if os.path.exists("files/pack"): shutil.rmtree("files/pack") os.mkdir("files/pack") @@ -47,10 +46,12 @@ class Pack: def compress(self) -> None: + print("Compressing") shutil.make_archive("files/pack", 'zip', "files/pack") shutil.rmtree("files/pack") def hash(self): + print("Hashing") sha1sum = hashlib.sha1() with open("files/pack.zip", "rb") as pack: block = pack.read(2**16) @@ -62,11 +63,13 @@ class Pack: hashfile.write(self.hash) def upload(self): + print("Uploading") self.b2_api.authorize_account("production", os.environ.get("B2_ID"), os.environ.get("B2_KEY")) self.bucket.upload_local_file(local_file="files/pack.zip", file_name="pack.zip") self.bucket.upload_local_file(local_file="files/hash", file_name="hash") - + def gethash(self): + return self.hash