youl commited on
Commit
c9443bb
·
verified ·
1 Parent(s): 8e212da

update with credentiale file creation

Browse files
Files changed (1) hide show
  1. utils.py +14 -1
utils.py CHANGED
@@ -1,8 +1,21 @@
1
  import os
2
  from google.cloud import vision
3
  import re
 
 
4
  ##
5
- os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'data/ocr_vision_token.json'
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  ##
8
  def info_new_cni(donnees):
 
1
  import os
2
  from google.cloud import vision
3
  import re
4
+ import json
5
+ import tempfile
6
  ##
7
+
8
+ def get_credentials():
9
+ creds_json_str = os.getenv("cloud_vision")
10
+
11
+ #create temporale file
12
+ with tempfile.NamedTemporaryFile(mode="w+",delete=False, suffix=".json") as temp:
13
+ temp.write(creds_json_str) #write the content in json format
14
+ temp_filename = temp.name
15
+
16
+ return temp_filename
17
+
18
+ os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = get_credentials()
19
 
20
  ##
21
  def info_new_cni(donnees):