remove state file config

pull/24/head
Etienne Trimaille 2015-12-21 18:25:38 +01:00
rodzic 5a61c1837d
commit 5e45e9c5c9
2 zmienionych plików z 7 dodań i 22 usunięć

Wyświetl plik

@ -70,13 +70,10 @@ for folder in folders:
exit() exit()
# Test files # Test files
state_file = None
osm_file = None osm_file = None
mapping_file = None mapping_file = None
post_import_file = None post_import_file = None
for f in listdir(default['SETTINGS']): for f in listdir(default['SETTINGS']):
if f == 'last.state.txt':
state_file = join(default['SETTINGS'], f)
if f.endswith('.pbf'): if f.endswith('.pbf'):
osm_file = join(default['SETTINGS'], f) osm_file = join(default['SETTINGS'], f)
@ -91,10 +88,6 @@ if not osm_file:
print >> stderr, 'OSM file *.pbf is missing in %s' % default['SETTINGS'] print >> stderr, 'OSM file *.pbf is missing in %s' % default['SETTINGS']
exit() exit()
if not state_file:
print >> stderr, 'State file last.state.txt is missing in %s' % default['SETTINGS']
exit()
if not mapping_file: if not mapping_file:
print >> stderr, 'Mapping file *.json is missing in %s' % default['SETTINGS'] print >> stderr, 'Mapping file *.json is missing in %s' % default['SETTINGS']
exit() exit()

Wyświetl plik

@ -22,7 +22,7 @@
from os.path import exists, join, isabs, abspath from os.path import exists, join, isabs, abspath
from os import listdir, environ from os import listdir, environ
from sys import exit from sys import exit
from subprocess import call from subprocess import call, Popen, PIPE
from datetime import datetime from datetime import datetime
from time import sleep from time import sleep
from sys import stderr from sys import stderr
@ -57,11 +57,8 @@ for folder in folders:
exit() exit()
# Test files # Test files
state_file = None
osm_file = None osm_file = None
for f in listdir(default['SETTINGS']): for f in listdir(default['SETTINGS']):
if f == 'last.state.txt':
state_file = join(default['SETTINGS'], f)
if f.endswith('.pbf'): if f.endswith('.pbf'):
osm_file = join(default['SETTINGS'], f) osm_file = join(default['SETTINGS'], f)
@ -73,10 +70,6 @@ for f in listdir(default['SETTINGS']):
default['BASE_URL'] = content_file.read() default['BASE_URL'] = content_file.read()
""" """
if not state_file:
print >> stderr, 'State file last.state.txt is missing in %s' % default['SETTINGS']
exit()
if not osm_file: if not osm_file:
print >> stderr, 'OSM file *.osm.pbf is missing in %s' % default['SETTINGS'] print >> stderr, 'OSM file *.osm.pbf is missing in %s' % default['SETTINGS']
exit() exit()
@ -101,14 +94,13 @@ while True:
else: else:
# Take the timestamp from original file. # Take the timestamp from original file.
state_file_settings = {} command = ['osmconvert', osm_file, '--out-timestamp']
with open(state_file) as a_file: processus = Popen(command, stdin=PIPE, stdout=PIPE, stderr=PIPE)
for line in a_file: timestamp, err = processus.communicate()
if '=' in line:
name, value = line.partition("=")[::2] # Remove new line
state_file_settings[name] = value timestamp = timestamp.strip()
timestamp = state_file_settings['timestamp'].strip()
print 'Timestamp from the original state file : %s' % timestamp print 'Timestamp from the original state file : %s' % timestamp
# Removing some \ in the timestamp. # Removing some \ in the timestamp.