Commit 5576782f authored by Akshay G's avatar Akshay G

config

parent 26bf0a5b
import os import os
from collections import namedtuple from collections import namedtuple
os.environ['config'] = '{"MONGO_URI": "mongodb://svc-ilens:svc2345@192.168.0.220:21017", "MONGO_DB":"ilens_wps", ' \ #os.environ['config'] = '{"MONGO_URI": "mongodb://svc-ilens:svc2345@192.168.0.220:21017", "MONGO_DB":"ilens_wps", ' \
'"MONGO_COLL": "serviceConfiguration"} ' # '"MONGO_COLL": "serviceConfiguration"} '
from scripts.pull_docs_mongo import PullEvents from scripts.pull_docs_mongo import PullEvents
from scripts.sqlite_ingestor import SQLiteHandler from scripts.sqlite_ingestor import SQLiteHandler
from scripts.cron_job import CRON from scripts.cron_job import CRON
from scripts.common.config import MONGO_DB_OBJ, MONGO_SERVICE_COLL, HOST_CONFIG from scripts.common.config import MONGO_DB_OBJ, MONGO_SERVICE_COLL, HOST_CONFIG
from datetime import datetime, timedelta from datetime import datetime, timedelta
from scripts.common.logsetup import logger from scripts.common.logsetup import logger
from scripts.cron_job import * from scripts.cron_job import *
from datetime import datetime from datetime import datetime
from dateutil import tz from dateutil import tz
get_in_out_dt_output = namedtuple("output", "dt_in_time dt_out_time punch_date") get_in_out_dt_output = namedtuple("output", "dt_in_time dt_out_time punch_date")
def create_db_obj(): def create_db_obj():
"""Creates and returns the database object """Creates and returns the database object
also initialise schemas in the data also initialise schemas in the data
Returns: Returns:
SQLiteHandler: Database object SQLiteHandler: Database object
""" """
db_obj = CRON() db_obj = CRON()
return db_obj return db_obj
def insert_records(msserver_obj, data): def insert_records(msserver_obj, data):
# METHOD 1: Hardcode zones: # METHOD 1: Hardcode zones:
from_zone = tz.gettz('UTC') from_zone = tz.gettz('UTC')
to_zone = tz.gettz('Asia/Kolkata') to_zone = tz.gettz('Asia/Kolkata')
print(to_zone) print(to_zone)
utc = datetime.utcnow() utc = datetime.utcnow()
utc = utc.replace(tzinfo=from_zone) utc = utc.replace(tzinfo=from_zone)
# Convert time zone # Convert time zone
central = utc.astimezone(to_zone) central = utc.astimezone(to_zone)
print(central) print(central)
data = { data = {
"job_run_date": central, "job_run_date": central,
"auto_update": 1, "auto_update": 1,
"shift_hours": 8, "shift_hours": 8,
"group_event_period_seconds": 300, "group_event_period_seconds": 300,
"over_time_hours": 3, "over_time_hours": 3,
"job_interval_minutes": 15 "job_interval_minutes": 15
} }
x = msserver_obj.insert_records(data) x = msserver_obj.insert_records(data)
print(x) print(x)
return x return x
def add(msserver_obj, date): def add(msserver_obj, date):
date = datetime.today() date = datetime.today()
msserver_obj.insertConfigTime(date) msserver_obj.insertConfigTime(date)
def main(): def main():
"""main function """main function
""" """
msserver_obj = create_db_obj() # Vamshi msserver_obj = create_db_obj() # Vamshi
insert_records(msserver_obj, '') insert_records(msserver_obj, '')
if __name__ == '__main__': if __name__ == '__main__':
main() main()
# #
# msserver_obj = create_db_obj() # msserver_obj = create_db_obj()
# # get_config(msserver_obj) # # get_config(msserver_obj)
# # insert_records(msserver_obj, '') # # insert_records(msserver_obj, '')
# # msserver_obj.insertConfigTime() # # msserver_obj.insertConfigTime()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment