Skip to content

Commit a746dd0

Browse files
chore(win32): username
1 parent e3af366 commit a746dd0

4 files changed

Lines changed: 8 additions & 10 deletions

File tree

src/aignostics/application/_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,9 @@ def application_run_upload(
493493
if not source_file_path.is_file():
494494
logger.warning("Source file '%s' does not exist.", row["referebce"])
495495
return False
496+
username = psutil.Process().username().replace("\\", "_")
496497
object_key = (
497-
f"{psutil.Process().username()}/{upload_prefix}/"
498-
f"{application_version.application_version_id}/{source_file_path.name}"
498+
f"{username}/{upload_prefix}/{application_version.application_version_id}/{source_file_path.name}"
499499
)
500500
platform_bucket_url = (
501501
f"{BucketService().get_bucket_protocol()}://{BucketService().get_bucket_name()}/{object_key}"

src/aignostics/bucket/_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def upload(
7777

7878
console.print(f"Found {files_count} files with total size of {humanize.naturalsize(total_bytes)}")
7979

80-
username = psutil.Process().username()
80+
username = psutil.Process().username().replace("\\", "_")
8181
timestamp = datetime.datetime.now(tz=datetime.UTC).strftime("%Y%m%d_%H%M%S")
8282
base_prefix = destination_prefix.format(username=username, timestamp=timestamp)
8383
base_prefix = base_prefix.strip("/")

tests/aignostics/bucket/cli_test.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_cli_bucket_flow(runner: CliRunner, tmpdir) -> None: # noqa: C901, PLR0
3131

3232
# Get username for path verification
3333
the_uuid = str(uuid.uuid4())[:8] # Use first 8 characters of a random UUID
34-
username = psutil.Process().username()
34+
username = psutil.Process().username().replace("\\", "_")
3535
test_prefix = f"{the_uuid}/{username}/test-cli"
3636

3737
# Step 1: Create test files in the temporary directory
@@ -87,12 +87,10 @@ def test_cli_bucket_flow(runner: CliRunner, tmpdir) -> None: # noqa: C901, PLR0
8787
file_path = f"{test_prefix}/dir1/file{i}.txt"
8888
else:
8989
file_path = f"{test_prefix}/dir2/file{i}.txt"
90-
assert file_path in result.output.replace("\\\\", "\\")
90+
assert file_path in normalize_output(result.stdout)
9191

9292
# Step 4: Download the files to a subdirectory and verify they match content-wise
93-
result = runner.invoke(
94-
cli, ["bucket", "download", test_prefix.replace("\\\\", "\\"), "--destination", tmpdir / "downloaded"]
95-
)
93+
result = runner.invoke(cli, ["bucket", "download", test_prefix, "--destination", tmpdir / "downloaded"])
9694
assert result.exit_code == 0
9795
assert "Summary: 9 downloaded, 0 failed, 9 total" in result.output
9896

@@ -138,7 +136,7 @@ def test_cli_bucket_flow(runner: CliRunner, tmpdir) -> None: # noqa: C901, PLR0
138136
file_path = f"{test_prefix}/dir1/file{i}.txt"
139137
else:
140138
file_path = f"{test_prefix}/dir2/file{i}.txt"
141-
assert file_path not in normalize_output(result.stdout).replace("\\\\", "\\")
139+
assert file_path not in normalize_output(result.stdout)
142140

143141
# Step 8: Try to delete a file that doesn't exist
144142
non_existent_file = f"{test_prefix}/file1.txt"

tests/aignostics/bucket/gui_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async def test_gui_bucket_flow(user: User, runner: CliRunner, tmp_path: Path, si
4444
assert "All files uploaded successfully!" in result.output
4545

4646
# Prep
47-
test_prefix = test_prefix.format(username=psutil.Process().username())
47+
test_prefix = test_prefix.format(username=psutil.Process().username().replace("\\", "_"))
4848

4949
# Step 3: Check the file is there
5050
result = runner.invoke(cli, ["bucket", "find"])

0 commit comments

Comments
 (0)