Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
msserver_cron_job
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dasharatha.vamshi
msserver_cron_job
Commits
5576782f
Commit
5576782f
authored
Jul 25, 2020
by
Akshay G
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config
parent
26bf0a5b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
72 deletions
+72
-72
cron-app.py
cron-app.py
+72
-72
No files found.
cron-app.py
View file @
5576782f
import
os
from
collections
import
namedtuple
os
.
environ
[
'config'
]
=
'{"MONGO_URI": "mongodb://svc-ilens:svc2345@192.168.0.220:21017", "MONGO_DB":"ilens_wps", '
\
'"MONGO_COLL": "serviceConfiguration"} '
from
scripts.pull_docs_mongo
import
PullEvents
from
scripts.sqlite_ingestor
import
SQLiteHandler
from
scripts.cron_job
import
CRON
from
scripts.common.config
import
MONGO_DB_OBJ
,
MONGO_SERVICE_COLL
,
HOST_CONFIG
from
datetime
import
datetime
,
timedelta
from
scripts.common.logsetup
import
logger
from
scripts.cron_job
import
*
from
datetime
import
datetime
from
dateutil
import
tz
get_in_out_dt_output
=
namedtuple
(
"output"
,
"dt_in_time dt_out_time punch_date"
)
def
create_db_obj
():
"""Creates and returns the database object
also initialise schemas in the data
Returns:
SQLiteHandler: Database object
"""
db_obj
=
CRON
()
return
db_obj
def
insert_records
(
msserver_obj
,
data
):
# METHOD 1: Hardcode zones:
from_zone
=
tz
.
gettz
(
'UTC'
)
to_zone
=
tz
.
gettz
(
'Asia/Kolkata'
)
print
(
to_zone
)
utc
=
datetime
.
utcnow
()
utc
=
utc
.
replace
(
tzinfo
=
from_zone
)
# Convert time zone
central
=
utc
.
astimezone
(
to_zone
)
print
(
central
)
data
=
{
"job_run_date"
:
central
,
"auto_update"
:
1
,
"shift_hours"
:
8
,
"group_event_period_seconds"
:
300
,
"over_time_hours"
:
3
,
"job_interval_minutes"
:
15
}
x
=
msserver_obj
.
insert_records
(
data
)
print
(
x
)
return
x
def
add
(
msserver_obj
,
date
):
date
=
datetime
.
today
()
msserver_obj
.
insertConfigTime
(
date
)
def
main
():
"""main function
"""
msserver_obj
=
create_db_obj
()
# Vamshi
insert_records
(
msserver_obj
,
''
)
if
__name__
==
'__main__'
:
main
()
#
# msserver_obj = create_db_obj()
# # get_config(msserver_obj)
# # insert_records(msserver_obj, '')
# # msserver_obj.insertConfigTime()
import
os
from
collections
import
namedtuple
#os.environ['config'] = '{"MONGO_URI": "mongodb://svc-ilens:svc2345@192.168.0.220:21017", "MONGO_DB":"ilens_wps", ' \
# '"MONGO_COLL": "serviceConfiguration"} '
from
scripts.pull_docs_mongo
import
PullEvents
from
scripts.sqlite_ingestor
import
SQLiteHandler
from
scripts.cron_job
import
CRON
from
scripts.common.config
import
MONGO_DB_OBJ
,
MONGO_SERVICE_COLL
,
HOST_CONFIG
from
datetime
import
datetime
,
timedelta
from
scripts.common.logsetup
import
logger
from
scripts.cron_job
import
*
from
datetime
import
datetime
from
dateutil
import
tz
get_in_out_dt_output
=
namedtuple
(
"output"
,
"dt_in_time dt_out_time punch_date"
)
def
create_db_obj
():
"""Creates and returns the database object
also initialise schemas in the data
Returns:
SQLiteHandler: Database object
"""
db_obj
=
CRON
()
return
db_obj
def
insert_records
(
msserver_obj
,
data
):
# METHOD 1: Hardcode zones:
from_zone
=
tz
.
gettz
(
'UTC'
)
to_zone
=
tz
.
gettz
(
'Asia/Kolkata'
)
print
(
to_zone
)
utc
=
datetime
.
utcnow
()
utc
=
utc
.
replace
(
tzinfo
=
from_zone
)
# Convert time zone
central
=
utc
.
astimezone
(
to_zone
)
print
(
central
)
data
=
{
"job_run_date"
:
central
,
"auto_update"
:
1
,
"shift_hours"
:
8
,
"group_event_period_seconds"
:
300
,
"over_time_hours"
:
3
,
"job_interval_minutes"
:
15
}
x
=
msserver_obj
.
insert_records
(
data
)
print
(
x
)
return
x
def
add
(
msserver_obj
,
date
):
date
=
datetime
.
today
()
msserver_obj
.
insertConfigTime
(
date
)
def
main
():
"""main function
"""
msserver_obj
=
create_db_obj
()
# Vamshi
insert_records
(
msserver_obj
,
''
)
if
__name__
==
'__main__'
:
main
()
#
# msserver_obj = create_db_obj()
# # get_config(msserver_obj)
# # insert_records(msserver_obj, '')
# # msserver_obj.insertConfigTime()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment