Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
Water Level Detector
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
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
21_22J-64
Water Level
Water Level Detector
Commits
05ee665f
Commit
05ee665f
authored
Mar 30, 2022
by
Rajasingam kokilan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rasperi.py
parent
3bc0126e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
0 deletions
+70
-0
watercontrol_for_rasperypi.py
watercontrol_for_rasperypi.py
+70
-0
No files found.
watercontrol_for_rasperypi.py
0 → 100644
View file @
05ee665f
from
__future__
import
print_function
import
operator
import
gspread
from
google.oauth2.service_account
import
Credentials
def
create_assertion_session_service_account
(
url
):
scopes
=
[
'https://www.googleapis.com/auth/spreadsheets'
,
'https://www.googleapis.com/auth/drive'
]
credentials
=
Credentials
.
from_service_account_file
(
'credentials.auth.json'
,
scopes
=
scopes
)
gc
=
gspread
.
authorize
(
credentials
)
sh
=
gc
.
open_by_url
(
url
)
worksheet
=
sh
.
sheet1
return
worksheet
def
dataIndexIdentification
(
url
):
worksheet
=
create_assertion_session_service_account
(
url
)
col_list
=
worksheet
.
row_values
(
1
)
jsonConfig
=
{}
d1
=
[]
for
i
,
data1
in
enumerate
(
col_list
,
start
=
0
):
commonColObject
=
{}
commonColObject
[
"index"
]
=
i
jsonConfig
[
col_list
[
i
]]
=
commonColObject
return
jsonConfig
def
classifier
(
water_level
,
url
):
search_keys
=
dataIndexIdentification
(
url
)
worksheet
=
create_assertion_session_service_account
(
url
)
count_array
=
[]
count_dict
=
{}
search_keys_array
=
[]
search_keys_dict
=
{}
for
key
,
value
in
search_keys
.
items
():
search_keys_dict
[
key
]
=
worksheet
.
col_values
(
value
[
'index'
]
+
1
)[
1
:]
count_dict
[
key
+
"_count"
]
=
0
count_array
.
append
(
count_dict
)
search_keys_array
.
append
(
search_keys_dict
)
water_levels
=
water_level
for
water_level
in
water_levels
:
for
search_key
in
search_keys_array
:
for
key
,
value
in
search_key
.
items
():
if
water_levels
in
value
:
for
k
,
v
in
count_array
[
0
]
.
items
():
if
k
==
key
+
"_count"
:
count_array
[
0
][
key
+
"_count"
]
=
count_array
[
0
][
key
+
"_count"
]
+
1
sorted_x
=
sorted
(
count_array
[
0
]
.
items
(),
key
=
operator
.
itemgetter
(
1
))
if
sorted_x
[
-
1
][
1
]
==
0
:
print
(
"income water persentage"
)
else
:
print
(
"number of door need oppen "
+
sorted_x
[
-
1
][
0
][:
-
6
]
+
" stay safe"
)
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