(self)
| 131 | return os.path.exists(os.path.join(self.s_path, self.dd_name)) |
| 132 | |
| 133 | def check_7z(self): |
| 134 | # Check the PATH var first |
| 135 | z_path = self.r.run({"args":["where.exe","7z.exe"]})[0].split("\n")[0].rstrip("\r") |
| 136 | self.z_path = next((x for x in (z_path,self.z_path64,self.z_path32) if x and os.path.isfile(x)),None) |
| 137 | if self.z_path: |
| 138 | return True |
| 139 | print("Didn't locate {} - downloading...".format(self.z_name)) |
| 140 | # Didn't find it - let's do some stupid stuff |
| 141 | # First we get our json response - or rather, try to, then parse it |
| 142 | # looking for the current version |
| 143 | dl_url = None |
| 144 | try: |
| 145 | json_data = json.loads(self.dl.get_string(self.z_json)) |
| 146 | v_num = json_data.get("release",{}).get("filename","").split("/")[-1].lower().split("-")[0].replace("7z","").replace(".exe","") |
| 147 | if len(v_num): |
| 148 | dl_url = self.z_url.replace("[[vers]]",v_num) |
| 149 | except: |
| 150 | pass |
| 151 | if not dl_url: |
| 152 | dl_url = self.z_url2 |
| 153 | temp = tempfile.mkdtemp() |
| 154 | dl_file = self.dl.stream_to_file(dl_url, os.path.join(temp, self.z_name)) |
| 155 | if not dl_file: # Didn't download right |
| 156 | shutil.rmtree(temp,ignore_errors=True) |
| 157 | return False |
| 158 | print("") |
| 159 | print("Installing 7zip...") |
| 160 | # From Tim Sutton's brigadier: https://github.com/timsutton/brigadier/blob/master/brigadier |
| 161 | out = self.r.run({"args":["msiexec", "/qn", "/i", os.path.join(temp, self.z_name)],"stream":True}) |
| 162 | if out[2] != 0: |
| 163 | shutil.rmtree(temp,ignore_errors=True) |
| 164 | print("Error ({})".format(out[2])) |
| 165 | print("") |
| 166 | self.u.grab("Press [enter] to exit...") |
| 167 | exit(1) |
| 168 | print("") |
| 169 | self.z_path = self.z_path64 if os.path.exists(self.z_path64) else self.z_path32 if os.path.exists(self.z_path32) else None |
| 170 | return self.z_path and os.path.exists(self.z_path) |
| 171 | |
| 172 | def check_bi(self): |
| 173 | # Checks for BOOTICEx64.exe in our scripts dir |
no test coverage detected