Skip to content

Commit d5d5446

Browse files
authored
Merge pull request #64 from HPCNow/main
froster v0.12.22
2 parents 22c45a3 + b17fce4 commit d5d5446

File tree

4 files changed

+26
-25
lines changed

4 files changed

+26
-25
lines changed

froster/froster.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,7 @@ def __init__(self):
9191
self.home_dir = os.path.expanduser('~')
9292

9393
# Froster's home directory
94-
self.froster_dir = os.path.join(sys.prefix)
95-
96-
# Froster's binary directory
97-
self.bin_dir = os.path.join(self.froster_dir, 'bin')
94+
self.froster_dir = os.path.dirname(os.path.realpath(shutil.which('froster')))
9895

9996
# Froster's data directory
10097
xdg_data_home = os.environ.get('XDG_DATA_HOME')
@@ -3080,13 +3077,14 @@ def _index_locally(self, folder):
30803077
f' ...folder already indexed at {folder_hotspot}. Use "-f" or "--force" flag to force indexing.\n')
30813078
return
30823079

3080+
30833081
# Run pwalk on given folder
30843082
with tempfile.NamedTemporaryFile() as pwalk_output:
30853083
with tempfile.NamedTemporaryFile() as pwalk_output_folders:
30863084
with tempfile.NamedTemporaryFile() as pwalk_output_folders_converted:
30873085

30883086
# Build the pwalk command
3089-
pwalk_bin = os.path.join(sys.prefix, 'bin', 'pwalk')
3087+
pwalk_bin = os.path.join(self.cfg.froster_dir, 'pwalk')
30903088
pwalkcmd = f'{pwalk_bin} --NoSnap --one-file-system --header'
30913089
mycmd = f'{pwalkcmd} "{folder}" > {pwalk_output.name}'
30923090

@@ -4285,6 +4283,8 @@ def _delete_locally(self, folder_to_delete):
42854283
f"Archive aws profile: {archived_folder_info['profile']}\n")
42864284
rme.write(f"Archiver user: {archived_folder_info['user']}\n")
42874285
rme.write(f'Archiver email: {self.cfg.email}\n')
4286+
rme.write(
4287+
f'froster-archives.json: {self.archive_json}\n')
42884288
rme.write(
42894289
f'Archive tool: https://github.com/dirkpetersen/froster\n')
42904290
rme.write(
@@ -5187,7 +5187,7 @@ def __init__(self, args: argparse.Namespace, cfg: ConfigManager):
51875187
self.cfg = cfg
51885188

51895189
# Set the Rclone executable path
5190-
self.rc = os.path.join(sys.prefix, 'bin', 'rclone')
5190+
self.rc = os.path.join(self.cfg.froster_dir, 'rclone')
51915191

51925192
# Set the Rclone environment variables
51935193
# Note: Keys are set in the AWS Boto __init__ function
@@ -6052,13 +6052,15 @@ def print_version(self):
60526052
def print_info(self):
60536053
'''Print froster info'''
60546054

6055+
froster_dir = os.path.dirname(os.path.realpath(shutil.which('froster')))
6056+
60556057
log(
60566058
f'froster v{pkg_resources.get_distribution("froster").version}\n')
60576059
log(f'Tools version:')
60586060
log(f' python v{platform.python_version()}')
6059-
log(' pwalk ', 'v'+subprocess.run([os.path.join(sys.prefix, 'bin', 'pwalk'), '--version'],
6061+
log(' pwalk ', 'v'+subprocess.run([os.path.join(froster_dir, 'pwalk'), '--version'],
60606062
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True).stderr.split('\n')[0].split()[2])
6061-
log(' ', subprocess.run([os.path.join(sys.prefix, 'bin', 'rclone'), '--version'],
6063+
log(' ', subprocess.run([os.path.join(froster_dir, 'rclone'), '--version'],
60626064
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True).stdout.split('\n')[0])
60636065

60646066
log(textwrap.dedent(f'''
@@ -6109,11 +6111,6 @@ def subcmd_config(self, cfg: ConfigManager, aws: AWSBoto):
61096111
if self.args.print:
61106112
return cfg.print_config()
61116113

6112-
# if self.args.monitor:
6113-
# froster_binary = os.path.join(cfg.bin_dir, 'froster')
6114-
# return cfg.add_systemd_cron_job(
6115-
# f'{froster_binary} restore --monitor', '30')
6116-
61176114
log(f'\n*****************************')
61186115
log(f'*** FROSTER CONFIGURATION ***')
61196116
log(f'*****************************\n')
@@ -7065,7 +7062,7 @@ def main():
70657062
cmd.print_help()
70667063

70677064
# Check if there are updates on froster every X days
7068-
if cfg.check_update() and args.subcmd not in ['update', 'upd']:
7065+
if cfg.configuration_done and cfg.check_update() and args.subcmd not in ['update', 'upd']:
70697066
cmd.subcmd_update(mute_no_update=True)
70707067

70717068
# Close the AWS session

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "froster"
7-
version = "0.12.21"
7+
version = "0.12.22"
88
description = "Froster is a tool for easy data transfer between local file systems and AWS S3 storage."
99
authors = ["Victor Machado <[email protected]>"]
1010
readme = "README.md"

tests/config.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
# Variables
22
import os
3+
import random
4+
import string
35
import tempfile
46

57

8+
def random_string(length=4):
9+
return ''.join(random.choices(string.ascii_lowercase + string.digits, k=length))
10+
611
NAME = "Test-Bob"
712
NAME_2 = "Test-Alice"
813
@@ -23,11 +28,11 @@
2328
NIH_SECTION = 'NIH'
2429
S3_SECTION = 'S3'
2530

26-
S3_BUCKET_NAME_CONFIG = 'froster-unittest-config'
27-
S3_BUCKET_NAME_CONFIG_2 = 'froster-unittest-config-2'
31+
S3_BUCKET_NAME_CONFIG = 'froster-unittest-config-' + random_string(4)
32+
S3_BUCKET_NAME_CONFIG_2 = 'froster-unittest-config-' + random_string(4)
2833

29-
S3_BUCKET_NAME_INDEX = 'froster-unittest-index'
30-
S3_BUCKET_NAME_INDEX_2 = 'froster-unittest-index-2'
34+
S3_BUCKET_NAME_INDEX = 'froster-unittest-index-' + random_string(4)
35+
S3_BUCKET_NAME_INDEX_2 = 'froster-unittest-index-' + random_string(4)
3136

3237
S3_ARCHIVE_DIR = 'froster_bob'
3338
S3_ARCHIVE_DIR_2 = 'froster_alice'

tests/generate_dummy_data.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ def generate_test_data():
4444

4545
# Create files in the base directory
4646
for dir in [base_dir, subdir1, subdir2]:
47-
create_file('small_1_' + random_string(), 1, dir, '1 days ago')
48-
create_file('small_2_' + random_string(), 1, dir, '10 days ago')
49-
create_file('medium_1_' + random_string(), 1100, dir, '100 days ago')
50-
create_file('medium_2_' + random_string(), 1100, dir, '1000 days ago')
51-
create_file('large_1_' + random_string(), 1100000, dir, '10 days ago')
52-
create_file('large_2_' + random_string(), 1100000, dir, '1000 days ago')
47+
create_file('small_1_' + random_string(), 1, dir, '1 days ago') # 1B
48+
create_file('small_2_' + random_string(), 1, dir, '10 days ago') # 1B
49+
create_file('medium_1_' + random_string(), 1100, dir, '100 days ago') # 1.1KB
50+
create_file('medium_2_' + random_string(), 1100, dir, '1000 days ago') # 1.1KB
51+
create_file('large_' + random_string(), 1100000000, dir, '10 days ago') # 1.1GB
5352

5453
return base_dir
5554

0 commit comments

Comments
 (0)