@@ -79,18 +79,15 @@ subprocess.check_output(cmd, shell=True)
79
79
os .chdir (os .path .join (project_root , "electrum" ))
80
80
81
81
crowdin_api_key = None
82
-
83
82
filename = os .path .expanduser ('~/.crowdin_api_key' )
84
83
if os .path .exists (filename ):
85
84
with open (filename ) as f :
86
85
crowdin_api_key = f .read ().strip ()
87
-
88
86
if "crowdin_api_key" in os .environ :
89
87
crowdin_api_key = os .environ ["crowdin_api_key" ]
90
-
91
88
if not crowdin_api_key :
92
89
print ('Missing crowdin_api_key. Cannot push.' )
93
- sys .exit (0 )
90
+ sys .exit (1 )
94
91
print ('Found crowdin_api_key. Will push updated source-strings to crowdin.' )
95
92
96
93
crowdin_project_id = 20482 # for "Electrum" project on crowdin
@@ -100,24 +97,30 @@ crowdin_file_id = 68 # for "/electrum-client/messages.pot"
100
97
global_headers = {"Authorization" : "Bearer {}" .format (crowdin_api_key )}
101
98
102
99
# client.storages.add_storage(f)
100
+ # https://support.crowdin.com/developer/api/v2/?q=api#tag/Storage/operation/api.storages.post
103
101
print (f"Uploading to temp storage..." )
104
102
url = f'https://api.crowdin.com/api/v2/storages'
105
103
with open (locale_file_name , 'rb' ) as f :
106
104
headers = {** global_headers , ** {"Crowdin-API-FileName" : crowdin_file_name }}
107
105
response = requests .request ("POST" , url , data = f , headers = headers )
106
+ response .raise_for_status ()
108
107
print ("" , "storages.add_storage:" , "-" * 20 , response .text , "-" * 20 , sep = "\n " )
109
108
storage_id = response .json ()["data" ]["id" ]
110
109
111
110
# client.source_files.update_file(projectId=crowdin_project_id, storageId=storage_id, fileId=crowdin_file_id)
111
+ # https://support.crowdin.com/developer/api/v2/?q=api#tag/Source-Files/operation/api.projects.files.put
112
112
print (f"Copying from temp storage and updating file in perm storage..." )
113
113
url = f'https://api.crowdin.com/api/v2/projects/{ crowdin_project_id } /files/{ crowdin_file_id } '
114
114
headers = {** global_headers , ** {"content-type" : "application/json" }}
115
115
response = requests .request ("PUT" , url , json = {"storageId" : storage_id }, headers = headers )
116
+ response .raise_for_status ()
116
117
print ("" , "source_files.update_file:" , "-" * 20 , response .text , "-" * 20 , sep = "\n " )
117
118
118
119
# client.translations.build_crowdin_project_translation(projectId=crowdin_project_id)
120
+ # https://support.crowdin.com/developer/api/v2/?q=api#tag/Translations/operation/api.projects.translations.builds.post
119
121
print (f"Rebuilding translations..." )
120
122
url = f'https://api.crowdin.com/api/v2/projects/{ crowdin_project_id } /translations/builds'
121
123
headers = {** global_headers , ** {"content-type" : "application/json" }}
122
124
response = requests .request ("POST" , url , headers = headers )
125
+ response .raise_for_status ()
123
126
print ("" , "translations.build_crowdin_project_translation:" , "-" * 20 , response .text , "-" * 20 , sep = "\n " )
0 commit comments