~widelands-dev/widelands/multiplayer-ui

« back to all changes in this revision

Viewing changes to utils/update_appdata.py

Merged lp:~widelands-dev/widelands/bug-1784113-desktop-file-utils:
Validate .desktop file on translation updates. Removed deprecated category from .desktop file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
118
118
 
119
119
input_file.close()
120
120
 
121
 
dest_filepath = base_path + '/debian/widelands.appdata.xml'
122
 
dest_file = codecs.open(dest_filepath, encoding='utf-8', mode='w')
 
121
appdata_filepath = base_path + '/debian/widelands.appdata.xml'
 
122
dest_file = codecs.open(appdata_filepath, encoding='utf-8', mode='w')
123
123
dest_file.write(appdata)
124
124
dest_file.close()
125
125
 
135
135
 
136
136
input_file.close()
137
137
 
138
 
dest_filepath = base_path + '/debian/org.widelands.widelands.desktop'
139
 
dest_file = codecs.open(dest_filepath, encoding='utf-8', mode='w')
 
138
desktop_filepath = base_path + '/debian/org.widelands.widelands.desktop'
 
139
dest_file = codecs.open(desktop_filepath, encoding='utf-8', mode='w')
140
140
dest_file.write(desktop)
141
141
dest_file.close()
142
142
 
143
143
print('Done!')
144
144
 
145
 
from subprocess import call
146
 
call(['appstreamcli', 'validate', base_path + '/debian/widelands.appdata.xml'])
 
145
from subprocess import call, Popen, PIPE
 
146
 
 
147
# Validata Appdata
 
148
call(['appstreamcli', 'validate', appdata_filepath])
 
149
 
 
150
# Validate desktop file. We don't get return codes, so we have to parse it
 
151
process = Popen(['desktop-file-validate', desktop_filepath],
 
152
                stderr=PIPE, stdout=PIPE, stdin=PIPE)
 
153
desktop_result = process.communicate()
 
154
if desktop_result[0] != '':
 
155
    print(desktop_result[0])
 
156
    sys.exit(1)