Skip to content

Commit 5b0f88c

Browse files
committed
Datetime changes for 2.7 and different way to call api with params
1 parent fed2b6d commit 5b0f88c

File tree

4 files changed

+6
-47
lines changed

4 files changed

+6
-47
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
urllib3==1.25.9
22
requests==2.24.0
33
six==1.15.0
4+
python-dateutil==2.8.1

tox.ini

Lines changed: 0 additions & 42 deletions
This file was deleted.

upcloud_api/cloud_manager/base.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import json
44
import requests
5-
import urllib.parse
65

76
from upcloud_api import UpCloudAPIError, __version__
87

@@ -29,8 +28,6 @@ def request(self, method, endpoint, body=None, params=None, timeout=-1, request_
2928
raise Exception('Invalid/Forbidden HTTP method')
3029

3130
url = 'https://api.upcloud.com/' + self.api_v + endpoint if request_to_api else endpoint
32-
if params:
33-
url += urllib.parse.urlencode(params, doseq=True)
3431
headers = {
3532
'Authorization': self.token,
3633
'User-Agent': 'upcloud-python-api/{}'.format(__version__)
@@ -50,6 +47,7 @@ def request(self, method, endpoint, body=None, params=None, timeout=-1, request_
5047
APIcall = getattr(requests, method.lower())
5148
res = APIcall(url,
5249
data=data,
50+
params=params,
5351
headers=headers,
5452
timeout=call_timeout)
5553

upcloud_api/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import itertools
22
from time import sleep
3-
from datetime import datetime, timezone
3+
from datetime import datetime
4+
from dateutil import tz
45

56
from upcloud_api import UpCloudClientError, UpCloudAPIError
67

@@ -48,5 +49,6 @@ def convert_datetime_string_to_object(datetime_string):
4849
"""
4950
Helper function to convert datetime string to object with local timezone
5051
"""
52+
local_tz = tz.tzlocal()
5153
datetime_object = datetime.strptime(datetime_string, '%Y-%m-%d %H:%M:%S')
52-
return datetime_object.astimezone().replace(microsecond=0).isoformat()
54+
return datetime_object.replace(tzinfo=local_tz, microsecond=0).isoformat()

0 commit comments

Comments
 (0)