Skip to content

Commit

Permalink
update logfetch to not use download endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ssalinas committed Jan 20, 2015
1 parent 56c8c73 commit 31eeb5d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions scripts/logfetch/live_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from singularity_request import get_json_response
import logfetch_base

DOWNLOAD_FILE_FORMAT = '{0}/sandbox/{1}/download'
DOWNLOAD_FILE_FORMAT = 'http://{0}:5051/files/download.json'
BROWSE_FOLDER_FORMAT = '{0}/sandbox/{1}/browse'

def download_live_logs(args):
Expand All @@ -20,20 +20,21 @@ def download_live_logs(args):
os.remove(f)
sys.stderr.write(colored('Downloading current live log files', 'blue') + '\n')
for task in tasks:
uri = DOWNLOAD_FILE_FORMAT.format(logfetch_base.base_uri(args), task)
metadata = files_json(args, task)
uri = DOWNLOAD_FILE_FORMAT.format(metadata['slaveHostname'])
service_log = '{0}-service.log'.format(task)
tail_log = '{0}-tail_of_finished_service.log'.format(task)
async_requests.append(
grequests.AsyncRequest('GET',uri ,
callback=generate_callback(uri, args.dest, service_log, args.chunk_size),
params={'path' : '{0}/service.log'.format(task)}
params={'path' : '{0}/{1}/service.log'.format(metadata['fullPathToRoot'], metadata['currentDirectory'])}
)
)
all_logs.append('{0}/{1}'.format(args.dest, service_log))
async_requests.append(
grequests.AsyncRequest('GET',uri ,
callback=generate_callback(uri, args.dest, tail_log, args.chunk_size),
params={'path' : '{0}/tail_of_finished_service.log'.format(task)}
params={'path' : '{0}/{1}/tail_of_finished_service.log'.format(metadata['fullPathToRoot'], metadata['currentDirectory'])}
)
)
all_logs.append('{0}/{1}'.format(args.dest, service_log))
Expand All @@ -42,7 +43,7 @@ def download_live_logs(args):
async_requests.append(
grequests.AsyncRequest('GET',uri ,
callback=generate_callback(uri, args.dest, logfile_name, args.chunk_size),
params={'path' : '{0}/logs/{1}'.format(task, log_file)}
params={'path' : '{0}/{1}/logs/{1}'.format(metadata['fullPathToRoot'], metadata['currentDirectory'], log_file)}
)
)
if logfile_name.endswith('.gz'):
Expand All @@ -59,6 +60,10 @@ def tasks_to_check(args):
else:
return logfetch_base.tasks_for_request(args)

def files_json(args, task):
uri = BROWSE_FOLDER_FORMAT.format(logfetch_base.base_uri(args), task)
return get_json_response(uri)

def logs_folder_files(args, task):
uri = BROWSE_FOLDER_FORMAT.format(logfetch_base.base_uri(args), task)
files_json = get_json_response(uri, {'path' : '{0}/logs'.format(task)})
Expand Down

0 comments on commit 31eeb5d

Please sign in to comment.