Skip to content

Commit

Permalink
fixed config module usage
Browse files Browse the repository at this point in the history
  • Loading branch information
shitwolfymakes committed Jun 3, 2022
1 parent 13515f8 commit 4edb87e
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions arm/ui/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ def get_info(directory):
file_size = os.path.getsize(os.path.join(directory, i))
file_size = round((file_size / 1024), 1)
file_size = f"{file_size :,.1f}"
create_time = strftime(cfg['DATE_FORMAT'], localtime(file_stats.st_ctime))
access_time = strftime(cfg['DATE_FORMAT'], localtime(file_stats.st_atime))
create_time = strftime(cfg.arm_config['DATE_FORMAT'], localtime(file_stats.st_ctime))
access_time = strftime(cfg.arm_config['DATE_FORMAT'], localtime(file_stats.st_atime))
# [file,most_recent_access,created, file_size]
file_list.append([i, access_time, create_time, file_size])
return file_list
Expand Down Expand Up @@ -320,7 +320,7 @@ def metadata_selector(func, query="", year="", imdb_id=""):
:return: json/dict object
"""
return_function = None
if cfg['METADATA_PROVIDER'].lower() == "tmdb":
if cfg.arm_config['METADATA_PROVIDER'].lower() == "tmdb":
app.logger.debug(f"provider tmdb - function: {func}")
if func == "search":
return_function = tmdb_search(str(query), str(year))
Expand All @@ -333,7 +333,7 @@ def metadata_selector(func, query="", year="", imdb_id=""):
return_function = tmdb_find(imdb_id)
app.logger.debug("No title or imdb provided")

elif cfg['METADATA_PROVIDER'].lower() == "omdb":
elif cfg.arm_config['METADATA_PROVIDER'].lower() == "omdb":
app.logger.debug(f"provider omdb - function: {func}")
if func == "search":
return_function = call_omdb_api(str(query), str(year))
Expand Down Expand Up @@ -365,9 +365,9 @@ def set_media_owner(dirpath, cur_dir, uid, gid):
# If there is no path saved in the job
if not job.path:
# Check logfile still exists
validate_logfile(job.logfile, "true", Path(os.path.join(cfg['LOGPATH'], job.logfile)))
validate_logfile(job.logfile, "true", Path(os.path.join(cfg.arm_config['LOGPATH'], job.logfile)))
# Find the correct path to use for fixing perms
directory_to_traverse = find_folder_in_log(os.path.join(cfg['LOGPATH'], job.logfile),
directory_to_traverse = find_folder_in_log(os.path.join(cfg.arm_config['LOGPATH'], job.logfile),
os.path.join(job.config.COMPLETED_PATH,
f"{job.title} ({job.year})"))
else:
Expand Down Expand Up @@ -415,7 +415,7 @@ def send_to_remote_db(job_id):
"""
job = models.Job.query.get(job_id)
return_dict = {}
api_key = cfg['ARM_API_KEY']
api_key = cfg.arm_config['ARM_API_KEY']

# This allows easy updates to the API url
base_url = "https://1337server.pythonanywhere.com"
Expand Down Expand Up @@ -723,19 +723,19 @@ def get_abcde_cfg(abcde_cfg_file):

def get_git_revision_hash() -> str:
"""Get full hash of current git commit"""
return subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=cfg['INSTALLPATH']).decode('ascii').strip()
return subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=cfg.arm_config['INSTALLPATH']).decode('ascii').strip()


def get_git_revision_short_hash() -> str:
"""Get short hash of current git commit"""
return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD'],
cwd=cfg['INSTALLPATH']).decode('ascii').strip()
cwd=cfg.arm_config['INSTALLPATH']).decode('ascii').strip()


def git_check_updates(current_hash) -> bool:
"""Check if we are on latest commit"""
git_update = subprocess.run(['git', 'fetch', 'https://github.com/1337-server/automatic-ripping-machine'],
cwd=cfg['INSTALLPATH'], check=False)
cwd=cfg.arm_config['INSTALLPATH'], check=False)
# git for-each-ref refs/remotes/origin --sort="-committerdate" | head -1
git_log = subprocess.check_output('git for-each-ref refs/remotes/origin --sort="-committerdate" | head -1',
shell=True, cwd="/opt/arm").decode('ascii').strip()
Expand All @@ -748,6 +748,6 @@ def git_check_updates(current_hash) -> bool:

def git_get_updates() -> dict:
"""update arm"""
git_log = subprocess.run(['git', 'pull'], cwd=cfg['INSTALLPATH'], check=False)
git_log = subprocess.run(['git', 'pull'], cwd=cfg.arm_config['INSTALLPATH'], check=False)
return {'stdout': git_log.stdout, 'stderr': git_log.stderr,
'return_code': git_log.returncode, 'form': 'ARM Update', "success": (git_log.returncode == 0)}

0 comments on commit 4edb87e

Please sign in to comment.