Omnibus commited on
Commit
8a1ba1b
1 Parent(s): c35955f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -127,9 +127,11 @@ def save_game(name,score,background_im,star_im,enemy_im):
127
  pass
128
 
129
  print(timestamp)
 
 
130
  try:
131
  api.upload_file(
132
- path_or_fileobj=os.path.abspath(f"{uid}_sky.png"),
133
  path_in_repo=f"{save_data.split('main/',1)[1]}/images/background/{game}-background_img.png",
134
  repo_id=save_data.split('datasets/',1)[1].split('/raw',1)[0],
135
  token=token_self,
@@ -137,10 +139,13 @@ def save_game(name,score,background_im,star_im,enemy_im):
137
  )
138
  except Exception as e:
139
  print (e)
140
- pass
 
 
 
141
  try:
142
  api.upload_file(
143
- path_or_fileobj=os.path.abspath(f"{uid}_star.png"),
144
  path_in_repo=f"{save_data.split('main/',1)[1]}/images/star/{game}-star_img.png",
145
  repo_id=save_data.split('datasets/',1)[1].split('/raw',1)[0],
146
  token=token_self,
@@ -148,10 +153,13 @@ def save_game(name,score,background_im,star_im,enemy_im):
148
  )
149
  except Exception as e:
150
  print (e)
151
- pass
 
 
 
152
  try:
153
  api.upload_file(
154
- path_or_fileobj=os.path.abspath(f"{uid}_enemy.png"),
155
  path_in_repo=f"{save_data.split('main/',1)[1]}/images/enemy/{game}-enemy_img.png",
156
  repo_id=save_data.split('datasets/',1)[1].split('/raw',1)[0],
157
  token=token_self,
 
127
  pass
128
 
129
  print(timestamp)
130
+ with open('tmp1.png','wb') as t1:
131
+ t1.write(f"{uid}_sky.png")
132
  try:
133
  api.upload_file(
134
+ path_or_fileobj='tmp1.png',
135
  path_in_repo=f"{save_data.split('main/',1)[1]}/images/background/{game}-background_img.png",
136
  repo_id=save_data.split('datasets/',1)[1].split('/raw',1)[0],
137
  token=token_self,
 
139
  )
140
  except Exception as e:
141
  print (e)
142
+ pass
143
+ t1.close()
144
+ with open('tmp2.png','wb') as t2:
145
+ t2.write(f"{uid}_star.png")
146
  try:
147
  api.upload_file(
148
+ path_or_fileobj='tmp2.png',
149
  path_in_repo=f"{save_data.split('main/',1)[1]}/images/star/{game}-star_img.png",
150
  repo_id=save_data.split('datasets/',1)[1].split('/raw',1)[0],
151
  token=token_self,
 
153
  )
154
  except Exception as e:
155
  print (e)
156
+ pass
157
+ t2.close()
158
+ with open('tmp3.png','wb') as t3:
159
+ t3.write(f"{uid}_enemy.png")
160
  try:
161
  api.upload_file(
162
+ path_or_fileobj='tmp3.png',
163
  path_in_repo=f"{save_data.split('main/',1)[1]}/images/enemy/{game}-enemy_img.png",
164
  repo_id=save_data.split('datasets/',1)[1].split('/raw',1)[0],
165
  token=token_self,