@@ -167,8 +167,8 @@ def pull_sleep_data(token, start=None):
167
167
# Get directory to write all files to, and create if necessary
168
168
script_path = os .path .abspath (__file__ )
169
169
script_dir = os .path .split (script_path )[0 ]
170
- write_dir = script_dir + ' \\ logs\\ '
171
-
170
+ write_dir = os . path . join ( script_dir , ' logs' )
171
+
172
172
if not os .path .exists (write_dir ):
173
173
os .makedirs (write_dir )
174
174
@@ -184,7 +184,8 @@ def pull_sleep_data(token, start=None):
184
184
print ("Access token expired." )
185
185
return 401
186
186
187
- fpath = write_dir + str (date ) + '.json'
187
+ fname = str (date ) + '.json'
188
+ fpath = os .path .join (write_dir , fname )
188
189
189
190
with open (fpath , 'w' ) as output :
190
191
# Data needs to be formatted as proper JSON, which means replacing
@@ -197,7 +198,7 @@ def pull_sleep_data(token, start=None):
197
198
198
199
json .dump (formatted_data , output )
199
200
200
- print ('Wrote sleep data to file /logs/{0}.json' . format ( str ( date ) ))
201
+ print ('Wrote sleep data to file %s' % ( fpath ))
201
202
202
203
# If there were more than 150 requests, notify user and provide the date
203
204
# to start on next time. The only time the try statement will fail is if
@@ -243,4 +244,4 @@ def pull_sleep_data(token, start=None):
243
244
refresh_token = token ["refresh_token" ]
244
245
token = get_access_token (refresh_token = refresh_token )
245
246
246
- pull_sleep_data (token , start_date )
247
+ pull_sleep_data (token , start_date )
0 commit comments