[ckan-changes] commit/ckanext-dgu: dread: [bin/gov-daily.py]: Set default directories to match those in live servers.
Bitbucket
commits-noreply at bitbucket.org
Wed Jun 22 16:15:08 UTC 2011
1 new changeset in ckanext-dgu:
http://bitbucket.org/okfn/ckanext-dgu/changeset/b1c678dfd287/
changeset: b1c678dfd287
user: dread
date: 2011-06-22 18:14:36
summary: [bin/gov-daily.py]: Set default directories to match those in live servers.
affected #: 1 file (705 bytes)
--- a/ckanext/dgu/bin/gov_daily.py Wed Jun 22 12:36:07 2011 +0100
+++ b/ckanext/dgu/bin/gov_daily.py Wed Jun 22 17:14:36 2011 +0100
@@ -35,7 +35,6 @@
USAGE = '''Daily script for government
Usage: python %s [config.ini]
''' % sys.argv[0]
-
if len(sys.argv) < 2 or sys.argv[1] in ('--help', '-h'):
err = 'Error: Please specify config file.'
print USAGE, err
@@ -46,22 +45,34 @@
load_config(path)
- import ckan.model as model
- import ckan.lib.dumper as dumper
from pylons import config
# settings
- log_filepath = os.path.join(os.path.expanduser(config.get('ckan.log_dir', '~')),
- 'gov-daily.log')
- dump_dir = os.path.expanduser(config.get('ckan.dump_dir', '~/dump'))
- ckan_instance_name = re.sub(r'[^\w.-]|https?', '',
- config.get('ckan.site_url', 'dgu'))
+ ckan_instance_name = os.path.basename(config_file).replace('.ini', '')
+ if ckan_instance_name != 'development':
+ default_dump_dir = '/var/lib/ckan/%s/static/dump' % ckan_instance_name
+ default_backup_dir = '/var/backup/ckan/%s' % ckan_instance_name
+ default_log_dir = '/var/log/ckan/%s' % ckan_instance_name
+ else:
+ # test purposes
+ default_dump_dir = '~/dump'
+ default_backup_dir = '~/backup'
+ default_log_dir = '~'
+ dump_dir = os.path.expanduser(config.get('ckan.dump_dir',
+ default_dump_dir))
+ backup_dir = os.path.expanduser(config.get('ckan.backup_dir',
+ default_backup_dir))
+ log_dir = os.path.expanduser(config.get('ckan.log_dir',
+ default_log_dir))
dump_filebase = config.get('ckan.dump_filename_base',
'data.gov.uk-ckan-meta-data-%Y-%m-%d')
- tmp_filepath = config.get('ckan.temp_filepath', '/tmp/dump.tmp')
- backup_dir = os.path.expanduser(config.get('ckan.backup_dir', '~/backup'))
+ dump_analysis_filebase = config.get('ckan.dump_analysis_base',
+ 'data.gov.uk-analysis')
backup_filebase = config.get('ckan.backup_filename_base',
ckan_instance_name + '.%Y-%m-%d.pg_dump')
+ log_filepath = os.path.join(log_dir, 'gov-daily.log')
+ print 'Logging to: %s' % log_filepath
+ tmp_filepath = config.get('ckan.temp_filepath', '/tmp/dump.tmp')
logging.basicConfig(filename=log_filepath, level=logging.INFO)
logging.info('----------------------------')
@@ -69,6 +80,9 @@
start_time = datetime.datetime.today()
logging.info(start_time.strftime('%H:%M %d-%m-%Y'))
+ import ckan.model as model
+ import ckan.lib.dumper as dumper
+
# Check database looks right
num_packages_before = model.Session.query(model.Package).count()
logging.info('Number of existing packages: %i' % num_packages_before)
@@ -103,8 +117,8 @@
# Dump analysis
logging.info('Creating dump analysis')
json_dump_filepath = os.path.join(dump_dir, '%s.json.zip' % dump_file_base)
- txt_filepath = os.path.join(dump_dir, 'package_counts.txt')
- csv_filepath = os.path.join(dump_dir, 'package_counts.csv')
+ txt_filepath = os.path.join(dump_dir, dump_analysis_filebase + '.txt')
+ csv_filepath = os.path.join(dump_dir, dump_analysis_filebase + '.csv')
run_info = get_run_info()
options = DumpAnalysisOptions(analyse_by_source=True)
analysis = DumpAnalysis(json_dump_filepath, options)
Repository URL: https://bitbucket.org/okfn/ckanext-dgu/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list