mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-19 10:51:34 +08:00
Small improvements to scripts/grt/export.py for testing.
- Don't rely on external sha256sum, use Python hashing (add utility to hash_util to enable this). - Drop unused galaxy_config from grt.yml.sample - it isn't used anywhere as far as I can tell.
This commit is contained in:
@@ -10,11 +10,30 @@ import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
BLOCK_SIZE = 1024 * 1024
|
||||
|
||||
sha1 = hashlib.sha1
|
||||
sha256 = hashlib.sha256
|
||||
sha = sha1
|
||||
md5 = hashlib.md5
|
||||
|
||||
|
||||
def memory_bound_hexdigest(hash_func, path=None, file=None):
|
||||
hasher = hash_func()
|
||||
if file is None:
|
||||
assert path is not None
|
||||
file = open(path, "rb")
|
||||
else:
|
||||
assert path is None, "Cannot specify path and path keyword arguments."
|
||||
|
||||
try:
|
||||
for block in iter(lambda: file.read(BLOCK_SIZE), b''):
|
||||
hasher.update(block)
|
||||
return hasher.hexdigest()
|
||||
finally:
|
||||
file.close()
|
||||
|
||||
|
||||
def md5_hash_file(path):
|
||||
"""
|
||||
Return a md5 hashdigest for a file or None if path could not be read.
|
||||
|
||||
@@ -7,7 +7,6 @@ import argparse
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
import time
|
||||
@@ -21,6 +20,7 @@ import galaxy
|
||||
import galaxy.config
|
||||
from galaxy.model import mapping
|
||||
from galaxy.objectstore import build_object_store_from_config
|
||||
from galaxy.util import hash_util
|
||||
from galaxy.util.properties import load_app_properties
|
||||
|
||||
sample_config = os.path.abspath(os.path.join(os.path.dirname(__file__), 'grt.yml.sample'))
|
||||
@@ -345,10 +345,8 @@ def main(argv):
|
||||
os.unlink(REPORT_BASE + '.' + name + '.tsv')
|
||||
|
||||
_times.append(('job_finish', time.time() - _start_time))
|
||||
sha = subprocess.check_output(['sha256sum', REPORT_BASE + '.tar.gz'])
|
||||
sha = hash_util.memory_bound_hexdigest(hash_util.sha256, REPORT_BASE + ".tar.gz")
|
||||
_times.append(('hash_finish', time.time() - _start_time))
|
||||
# Strip out to space
|
||||
sha = sha[0:sha.index(' ')]
|
||||
|
||||
# Now serialize the individual report data.
|
||||
with open(REPORT_BASE + '.json', 'w') as handle:
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
# Location of your galaxy config file. The radio telescope will need to
|
||||
# partially initialize a copy of galaxy.
|
||||
galaxy_config: config/galaxy.ini
|
||||
|
||||
grt:
|
||||
# Go to https://telescope.galaxyproject.org to obtain an Instance ID and API key
|
||||
instance_id:
|
||||
|
||||
Reference in New Issue
Block a user