Skip to content

Commit 65d7cdb

Browse files
committed
pmcjoder provider improvements:
- fixed timezone - ran black formatter, isort and flake8 linter to make cicd happy (see README.md)
1 parent 6d35f9f commit 65d7cdb

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
* @ysavary
22
/providers/windspots.py @Skyrider31
33
/providers/gxaircom.py @gereic
4+
/providers/pmcjoder.py @MichalBryxi

providers/pmcjoder.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
import arrow
21
import re
2+
from zoneinfo import ZoneInfo
3+
4+
import arrow
35
import requests
46
from lxml import html
57

68
from winds_mobi_provider import Q_, Pressure, Provider, ProviderException, StationNames, StationStatus, ureg
79

8-
class MyProvider(Provider):
10+
11+
class PmcJoder(Provider):
912
provider_code = "pmcjoder"
1013
provider_name = "pmcjoder.ch"
1114
provider_url = "https://www.pmcjoder.ch/webcam/neuhaus/wetterstation/wx.htm"
1215

16+
timezone = ZoneInfo("Europe/Zurich")
17+
1318
wind_directions = {
1419
"N": 0,
1520
"NNO": 1 * (360 / 16),
@@ -35,17 +40,15 @@ def extract_timestamp(self, data_str):
3540
if match:
3641
time_str = match.group(1)
3742
date_str = match.group(2)
38-
43+
3944
# Combine date and time strings
4045
datetime_str = f"{date_str} {time_str}"
41-
46+
4247
# Parse the combined string using arrow
43-
datetime_obj = arrow.get(datetime_str, "D/M/YY H:mm")
44-
48+
datetime_obj = arrow.get(datetime_str, "D/M/YY H:mm").replace(tzinfo=self.timezone)
49+
4550
# Convert to Unix timestamp
46-
int_timestamp = datetime_obj.int_timestamp
47-
print(int_timestamp)
48-
return int_timestamp
51+
return datetime_obj.int_timestamp
4952
else:
5053
raise ValueError("Date and time not found in the provided string")
5154

@@ -55,18 +58,18 @@ def process_data(self):
5558
url = "https://www.pmcjoder.ch/webcam/neuhaus/wetterstation/details.htm"
5659

5760
page = requests.get(url, timeout=(self.connect_timeout, self.read_timeout))
58-
61+
5962
tree = html.fromstring(page.content)
6063

61-
date_blob = tree.xpath('//table//tr[3]//td[1]//font//text()')[0]
64+
date_blob = tree.xpath("//table//tr[3]//td[1]//font//text()")[0]
6265

6366
values = tree.xpath("//table//tr[position() >= 5 and position() <= 27]//td[2]//text()")
6467
values = [value.strip() for value in values]
6568

6669
data = [
6770
{
6871
"id": "segelclub-neuhaus-interlaken",
69-
"shortName": "neuhuus",
72+
"shortName": "Neuhuus",
7073
"name": "Segelclub Neuhaus-Interlaken",
7174
"latitude": 46.736866,
7275
"longitude": 7.654292,
@@ -122,9 +125,9 @@ def process_data(self):
122125
self.log.info("...Done !")
123126

124127

125-
def my_provider():
126-
MyProvider().process_data()
128+
def pmcjoder():
129+
PmcJoder().process_data()
127130

128131

129132
if __name__ == "__main__":
130-
my_provider()
133+
pmcjoder()

run_scheduler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def run_scheduler():
5050
("providers.meteoswiss:meteoswiss", 5),
5151
("providers.pdcs:pdcs", 5),
5252
("providers.pioupiou:pioupiou", 5),
53+
("providers.pmcjoder:pmcjoder", 5),
5354
("providers.romma:romma", 5),
5455
("providers.slf:slf", 5),
5556
("providers.thunerwetter:thunerwetter", 5),

0 commit comments

Comments
 (0)