forked from patrickloeber/python-github-action-template
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
Latest commit
34 lines (28 loc) · 933 Bytes
/
Copy pathmain.py
File metadata and controls
34 lines (28 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
importlogging
importlogging.handlers
importos
importrequests
logger=logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger_file_handler=logging.handlers.RotatingFileHandler(
"status.log",
maxBytes=1024*1024,
backupCount=1,
encoding="utf8",
)
formatter=logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
logger_file_handler.setFormatter(formatter)
logger.addHandler(logger_file_handler)
try:
SOME_SECRET=os.environ["SOME_SECRET"]
exceptKeyError:
SOME_SECRET="Token not available!"
#logger.info("Token not available!")
#raise
if__name__=="__main__":
logger.info(f"Token value: {SOME_SECRET}")
r=requests.get('https://weather.talkpython.fm/api/weather/?city=Berlin&country=DE')
ifr.status_code==200:
data=r.json()
temperature=data["forecast"]["temp"]
logger.info(f'Weather in Berlin: {temperature}')