Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nxdblmbackendpython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Alexander Perez
nxdblmbackendpython
Commits
2ce9945f
Commit
2ce9945f
authored
5 years ago
by
Quentin Codelupi
Browse files
Options
Downloads
Patches
Plain Diff
[add] check data before start pulling
parent
3407da85
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.idea/inspectionProfiles/Project_Default.xml
+1
-1
1 addition, 1 deletion
.idea/inspectionProfiles/Project_Default.xml
routine_pull.py
+53
-16
53 additions, 16 deletions
routine_pull.py
with
54 additions
and
17 deletions
.idea/inspectionProfiles/Project_Default.xml
+
1
−
1
View file @
2ce9945f
...
...
@@ -3,7 +3,7 @@
<option
name=
"myName"
value=
"Project Default"
/>
<inspection_tool
class=
"DuplicatedCode"
enabled=
"true"
level=
"WEAK WARNING"
enabled_by_default=
"true"
>
<Languages>
<language
minSize=
"
146
"
name=
"Python"
/>
<language
minSize=
"
213
"
name=
"Python"
/>
</Languages>
</inspection_tool>
<inspection_tool
class=
"PyUnresolvedReferencesInspection"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
>
...
...
This diff is collapsed.
Click to expand it.
routine_pull.py
+
53
−
16
View file @
2ce9945f
import
mysql.connector
import
time
import
property_pull
import
pytimber
as
pytimber
...
...
@@ -22,19 +23,19 @@ def start_pull(_fill_infos, _devices=None):
if
_devices
is
None
:
_devices
=
[
'
BLMED.06L7.B1B30_TCPA.A6L7.B1
'
]
print
(
fill_infos
)
print
(
_
fill_infos
)
if
_fill_infos
[
"
endTime
"
]
is
None
:
return
-
1
for
iDevice
in
_devices
:
property_pull
.
property_pull
(
fill_infos
[
'
fillNumber
'
],
'
ALL
'
,
iDevice
,
fill_infos
[
'
startTime
'
].
strftime
(
"
%Y-%m-%d %H:%M:%S.000
"
),
fill_infos
[
'
endTime
'
].
strftime
(
"
%Y-%m-%d %H:%M:%S.000
"
))
property_pull
.
property_pull
(
_
fill_infos
[
'
fillNumber
'
],
'
ALL
'
,
iDevice
,
_
fill_infos
[
'
startTime
'
].
strftime
(
"
%Y-%m-%d %H:%M:%S.000
"
),
_
fill_infos
[
'
endTime
'
].
strftime
(
"
%Y-%m-%d %H:%M:%S.000
"
))
for
iMode
in
fill_infos
[
"
beamModes
"
]:
for
iMode
in
_
fill_infos
[
"
beamModes
"
]:
print
(
iMode
[
'
mode
'
])
property_pull
.
property_pull
(
fill_infos
[
'
fillNumber
'
],
iMode
[
'
mode
'
],
iDevice
,
property_pull
.
property_pull
(
_
fill_infos
[
'
fillNumber
'
],
iMode
[
'
mode
'
],
iDevice
,
iMode
[
'
startTime
'
].
strftime
(
"
%Y-%m-%d %H:%M:%S.000
"
),
iMode
[
'
endTime
'
].
strftime
(
"
%Y-%m-%d %H:%M:%S.000
"
))
...
...
@@ -47,16 +48,29 @@ def start_pull(_fill_infos, _devices=None):
'''
if
__name__
==
'
__main__
'
:
def
routine_pull
(
_start_fill
=
None
,
_end_fill
=
None
)
:
ldb
=
pytimber
.
LoggingDB
()
# res = ldb.get('HX:FILLN', datetime.datetime.now())
# fillNumber = int(res['HX:FILLN'][1][0])
fill_number
=
7493
fill_infos
=
ldb
.
getLHCFillData
(
fill_number
,
False
)
gcursor
=
mydb
.
cursor
()
_start_fill
=
None
_end_fill
=
None
if
_start_fill
is
None
and
_end_fill
is
None
:
res
=
ldb
.
get
(
'
HX:FILLN
'
,
dt
.
datetime
.
now
())
new_fill_number
=
int
(
res
[
'
HX:FILLN
'
][
1
][
0
])
print
(
new_fill_number
)
gcursor
.
execute
(
'
select max(name) from fill limit 1;
'
)
last_fill_pulled
=
gcursor
.
fetchone
()[
0
]
print
(
last_fill_pulled
)
if
new_fill_number
==
last_fill_pulled
:
print
(
'
already pulled last fill
'
)
return
-
1
else
:
new_fill_number
=
_end_fill
last_fll_pulled
=
_start_fill
-
1
# Select only the first 6 devices Cause: not all device works properly with NXCALS yet
gcursor
.
execute
(
'
select name from device limit 6
'
)
devices_request
=
gcursor
.
fetchall
()
devices
=
[]
...
...
@@ -66,6 +80,29 @@ if __name__ == '__main__':
gcursor
.
close
()
mydb
.
close
()
print
(
devices
)
fill_number
=
7472
fill_infos
=
ldb
.
getLHCFillData
(
fill_number
,
False
)
start_pull
(
fill_infos
,
devices
)
'''
for iFill in range(last_fill_pulled + 1, new_fill_number):
fill_infos = ldb.getLHCFillData(iFill, False)
# check if the fill is finished
if fill_infos[
'
endTime
'
] is None:
break
# check if data is too new
midnight_stamp = dt.datetime.now().replace(second=0, minute=0, hour=0) - dt.timedelta(days=1)
if time.mktime(midnight_stamp.timetuple()) < fill_infos[
'
endTime
'
]:
continue
start_pull(fill_infos, devices)
'''
if
__name__
==
'
__main__
'
:
routine_pull
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment