def __init__(self, appFilepath, isToNotifyStartup=True): print('App start: {}'.format(appFilepath)) file_dirpath = OsExpert.path_backstep(appFilepath) parent_dirpath = OsExpert.path_backstep(file_dirpath) App.initialize_in_dirs(logconfig_dirpath=file_dirpath, appconfig_dirpath=parent_dirpath) if isToNotifyStartup is True: NetworkExpert.tryAppNotifyByEmail(appFilepath, 'service is starting')
df_to_append, format='table', data_columns=True) row_count = h5.get_storer(job.uid).nrows Log.d('...h5 key {}, row count is {}', job.uid, row_count) except Exception as append_error: raise append_error Log.d('...time spent adding to h5: {:.2f}s', time.time() - h5_process_start_time) row_processing_time = time.time() - subset_process_start_time Log.d('...total time spent on subset: {:.2f}s ({:.2f}s per row)', row_processing_time, row_processing_time / row_process_count) return transaction_min_timestamp if __name__ == '__main__': file_dirpath = OsExpert.path_backstep(__file__) pd.options.display.float_format = '{:.2f}'.format try: app = GeneratorApp() app.feed_jobs_forever( job_changed_handler=lambda job: None #Log.w('dummy callback for job: {}', job.uid) ) except KeyboardInterrupt: print('\n\nKeyboardInterrupt\n') except Exception as e: Log.c('app failed: {}', e) stacktrace = OsExpert.stacktrace() Log.d('stacktrace:\n{}', stacktrace)
import sys; sys.path.append('..') import os import asyncio from applogging import Log from core import AppConfig, OsExpert, Timeout import traceback import time AppConfig.initialize_in_file_dir( OsExpert.path_backstep(__file__) ) class Parser(): def __init__(self): wfPath = "/tmp/my_fifo2" wp = None try: if not os.path.exists(wfPath): os.mkfifo(wfPath) while True: is_sent = False try: with Timeout(1): with open(wfPath, 'w') as wp: print('sending..') wp.write("a write!\n") print('sent') is_sent = True time.sleep(1) except TimeoutError: if not is_sent:
import sys; sys.path.append('../../src/fetch') sys.path.append('../../src/python') from app import App import unittest from core import OsExpert from db import DatabaseGateway class TestCase(unittest.TestCase): def setUp(self): self.db = DatabaseGateway() pass def test_watch_triggers_alert(self): raise NotImplementedError() if __name__ == '__main__': parent_dirpath = OsExpert.path_backstep(__file__, backsteps=2) App.initialize_in_dir(parent_dirpath) unittest.main()
else: exceed_count = 0 for i, row in datafetch_apis_frame.iterrows(): datafetch_api_id = row['id'] write_idle_seconds = row['write_idle_seconds'] result_frequency_seconds = row['result_frequency_seconds'] if write_idle_seconds > result_frequency_seconds: exceed_count += 1 idle_time_str = Timespan.from_seconds( write_idle_seconds).as_string() warn_message = 'datafetch api id {} has exceeded its {} second limit (idle time {})'.format( datafetch_api_id, result_frequency_seconds, idle_time_str) Log.w(warn_message) Log.d('watch check done, exceed count: {}', exceed_count) if __name__ == '__main__': file_dirpath = OsExpert.path_backstep(__file__) parent_dirpath = OsExpert.path_backstep(file_dirpath) App.initialize_in_dirs(logconfig_dirpath=file_dirpath, appconfig_dirpath=parent_dirpath) try: WatchApp().watch_continuously(watch_interval_seconds=15) except KeyboardInterrupt: print('\n\nKeyboardInterrupt\n') except Exception as e: Log.c('app failed: {}', e) stacktrace = OsExpert.stacktrace() Log.d('stacktrace:\n{}', stacktrace)
import json import time import configparser import io import os import hashlib import requests import hmac import websocket import simplejson as json from applogging import Log from core import AppConfig, OsExpert from db import DatabaseGateway sys.path.append('..') AppConfig.initialize_in_file_dir(OsExpert.path_backstep(__file__)) file_path = os.path.realpath(__file__) print(file_path) db = DatabaseGateway() datafetch_api_id = db.datafetch_api_id_by_handler_filepath(file_path) print(datafetch_api_id) exit() def prettyJson(jsonData): return json.dumps(jsonData, indent=4, sort_keys=True) publicKey = AppConfig.setting("BITCOINAVERAGE_PUBLIC_KEY") secretKey = AppConfig.setting("BITCOINAVERAGE_SECRET_KEY") url = "https://apiv2.bitcoinaverage.com/websocket/get_ticket"