Skip to content

Commit

Permalink
move default download path and file name to pre_operations
Browse files Browse the repository at this point in the history
  • Loading branch information
HuiquanJiang-ms committed Jul 10, 2024
1 parent 6f8768f commit 9322e74
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/acat/azext_acat/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import os
from knack.log import get_logger
from azure.cli.core.aaz import register_client, AAZClientConfiguration
from azure.cli.core.aaz import register_client, AAZClientConfiguration, has_value
from azure.cli.core.commands import LongRunningOperation
from azure.cli.core.aaz._client import AAZMgmtClient
from .utils import (
Expand Down Expand Up @@ -205,12 +205,12 @@ def _build_arguments_schema(cls, *args, **kwargs):
def _output(self, *args, **kwargs):
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)

downloadType = str(self.ctx.args["downloadType"])
path = self.ctx.args["path"] or os.getcwd()
fname = self.ctx.args["name"] or downloadType
fullpath = os.path.join(path, fname) + (
".pdf" if downloadType == "CompliancePdfReport" else ".csv"
)
args=self.ctx.args
downloadType = args.download_type.to_serialized_data()

fullpath = os.path.join(
args.path.to_serialized_data(), args.name.to_serialized_data()
) + (".pdf" if downloadType == "CompliancePdfReport" else ".csv")

if downloadType == "CompliancePdfReport":
import urllib.request
Expand All @@ -237,6 +237,12 @@ def pre_operations(self):
f"No snapshot found for report {self.ctx.args.report_name}"
)
args.snapshot_name = snapshot_name
downloadType = args.download_type.to_serialized_data()

if not has_value(args.path):
args.path = os.getcwd()
if not has_value(args.name):
args.name = downloadType


class GetControlAssessment(_AcatListSnapshot):
Expand Down

0 comments on commit 9322e74

Please sign in to comment.