Skip to content

Commit 5aeab64

Browse files
authored
Merge pull request #3 from failathon/master
Resolve path resolution cross-platform
2 parents 6922355 + b59d6e8 commit 5aeab64

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

fitbit.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ def pull_sleep_data(token, start=None):
167167
# Get directory to write all files to, and create if necessary
168168
script_path = os.path.abspath(__file__)
169169
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+
172172
if not os.path.exists(write_dir):
173173
os.makedirs(write_dir)
174174

@@ -184,7 +184,8 @@ def pull_sleep_data(token, start=None):
184184
print("Access token expired.")
185185
return 401
186186

187-
fpath = write_dir + str(date) + '.json'
187+
fname = str(date) + '.json'
188+
fpath = os.path.join(write_dir, fname)
188189

189190
with open(fpath, 'w') as output:
190191
# Data needs to be formatted as proper JSON, which means replacing
@@ -197,7 +198,7 @@ def pull_sleep_data(token, start=None):
197198

198199
json.dump(formatted_data, output)
199200

200-
print('Wrote sleep data to file /logs/{0}.json'.format(str(date)))
201+
print('Wrote sleep data to file %s' % (fpath))
201202

202203
# If there were more than 150 requests, notify user and provide the date
203204
# 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):
243244
refresh_token = token["refresh_token"]
244245
token = get_access_token(refresh_token = refresh_token)
245246

246-
pull_sleep_data(token, start_date)
247+
pull_sleep_data(token, start_date)

0 commit comments

Comments
 (0)