Skip to content

Commit 37079b7

Browse files
author
Bin Zhang
committed
Merge pull request cocos2d#170 from ZhangZiqi/develop
fix uncaught exception for open ant.properties
2 parents 3615346 + d74ebfe commit 37079b7

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

plugins/project_compile/build_android.py

+15-14
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def _parse_cfg(self):
9494

9595
def _write_ant_properties(self, cfg):
9696
ant_cfg_file = os.path.join(self.app_android_root, "ant.properties")
97-
file_obj = open(ant_cfg_file, "a")
97+
file_obj = open(ant_cfg_file, "a+")
9898
for key in cfg.keys():
9999
str_cfg = "%s=%s\n" % (key, cfg[key])
100100
file_obj.write(str_cfg)
@@ -104,23 +104,24 @@ def _write_ant_properties(self, cfg):
104104
def _move_cfg(self, cfg):
105105
# add into ant.properties
106106
ant_cfg_file = os.path.join(self.app_android_root, "ant.properties")
107-
file_obj = open(ant_cfg_file)
108-
pattern = re.compile(r"^key\.store=(.+)")
109-
keystore = None
110-
for line in file_obj:
111-
str1 = line.replace(' ', '')
112-
str2 = str1.replace('\t', '')
113-
match = pattern.match(str2)
114-
if match is not None:
115-
keystore = match.group(1)
116-
break
117-
118-
file_obj.close()
107+
try:
108+
keystore = None
109+
file_obj = open(ant_cfg_file)
110+
pattern = re.compile(r"^key\.store=(.+)")
111+
for line in file_obj:
112+
str1 = line.replace(' ', '')
113+
str2 = str1.replace('\t', '')
114+
match = pattern.match(str2)
115+
if match is not None:
116+
keystore = match.group(1)
117+
break
118+
file_obj.close()
119+
except:
120+
pass
119121

120122
if keystore is None:
121123
# ant.properties not have the config for sign
122124
self._write_ant_properties(cfg)
123-
124125
def remove_c_libs(self, libs_dir):
125126
for file_name in os.listdir(libs_dir):
126127
lib_file = os.path.join(libs_dir, file_name)

0 commit comments

Comments
 (0)