예제 #1
0
파일: views.py 프로젝트: mor1/acp_web
def bt_read_latest():
    '''
    Read the current data monitor file
    '''
    filename = 'btjourney/journeytimes/data_monitor_json/post_data.json'
    try:
        return util.read_json(filename)
    except FileNotFoundError:
        return {'request_data': []}
예제 #2
0
def get_parking_monitor(parking_id, suffix=''):
    '''
    Get recent or previous-recent data for a particular car park
    '''
    config = get_parking_config(parking_id)
    feed_id = config['feed_id']
    # Read latest data
    filename = ('{0}/data_monitor_json/post_data.json{1}'.format(
        feed_id, suffix))
    data = util.read_json(filename)
    # Find this car park
    for value in data['request_data']:
        if value['parking_id'] == parking_id:
            # Populate car park record with feed_id & ts from envelope
            value['feed_id'] = data['feed_id']
            value['ts'] = data['ts']
            value['acp_ts'] = value['ts']
            return value
    raise NotFound("No data found for '{0}'".format(parking_id))
예제 #3
0
from api.util import file_load, file_write, file_exists, get_files, get_tail, get_subdirs, read_json
from api.util import errorinfo, script_name, process_theme, load_index, dir_exists, find_file
from api.parser import get_bs, get_res, get_css, get_js, get_img, get_links, node_info

# Entry point
if __name__ == "__main__":

    # Check input
    if len(sys.argv) != 2:
        print(' ** Help: ' + script_name() + ' <input.json>')
        sys.exit()

    json_name = sys.argv[1]
    json_contents = None

    retCode, errInfo, DIR_LIST, REPLACE_MAP = read_json(json_name)

    if COMMON.OK != retCode:
        print('** Error: ' + errInfo)
        sys.exit()

    with open(json_name) as json_file:
        json_contents = json.load(json_file)

    v_repo = json_contents['base']['repo']
    v_build = json_contents['base']['build']
    v_build_out = json_contents['base']['output']
    v_prod = json_contents['base']['build_prod']
    v_prod_out = json_contents['base']['output_prod']

    print('REPO      -> ' + v_repo)
예제 #4
0
파일: views.py 프로젝트: mor1/acp_web
def bt_read_config(which, id):
    '''
    Return the link, route or site config for id
    '''
    filename = 'btjourney/locations/data_{0}/{1}.json'.format(which, id)
    return util.read_json(filename)
예제 #5
0
from api.common import COMMON, ASSETS_MAP, BS_TAG, TMPL
from api.util import file_load, file_write, file_exists, get_files, get_tail, get_subdirs, read_json
from api.util import errorinfo, script_name, process_theme, process_theme_files, load_index, theme_load_files, file_print_assets, name_from_path
from api.parser import get_bs, get_res, get_css, get_js, get_img, get_links, node_info

# Entry point
if __name__ == "__main__":

    # Check input
    if len(sys.argv) != 2:
        print(' ** Help: ' + script_name() + ' <input.json>')
        sys.exit()

    # Read Meta data
    input_file = sys.argv[1]
    retCode, errInfo, DIR_LIST, REPLACE_MAP = read_json(input_file)

    if COMMON.OK != retCode:
        print('** Error: ' + errInfo)
        sys.exit()

    # Read Files (we can have local paths in CSS, JS)
    retCode, errInfo, FILES_LIST = theme_load_files(
        DIR_LIST, 'html')  # scan for html files
    retCode, errInfo, FILES_CSS = theme_load_files(
        DIR_LIST, 'css')  # scan for CSS  files
    retCode, errInfo, FILES_JS = theme_load_files(DIR_LIST,
                                                  'js')  # scan for JS   files

    # Merge all lists into a single one
    FILES_LIST = {**FILES_LIST, **FILES_CSS}  # merge dicts