MCPcopy
hub / github.com/corpnewt/gibMacOS / check_dd

Method check_dd

MakeInstall.py:98–131  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

96 return disks
97
98 def check_dd(self):
99 # Checks if ddrelease64.exe exists in our Scripts dir
100 # and if not - downloads it
101 #
102 # Returns True if exists/downloaded successfully
103 # or False if issues.
104 # Check for dd.exe in the current dir
105 if os.path.exists(os.path.join(self.s_path, self.dd_name)):
106 # print("Located {}!".format(self.dd_name))
107 # Got it
108 return True
109 print("Couldn't locate {} - downloading...".format(self.dd_name))
110 temp = tempfile.mkdtemp()
111 z_file = os.path.basename(self.dd_url)
112 # Now we need to download
113 self.dl.stream_to_file(self.dd_url, os.path.join(temp,z_file))
114 print(" - Extracting...")
115 # Extract with built-in tools \o/
116 cwd = os.getcwd()
117 os.chdir(temp)
118 with zipfile.ZipFile(os.path.join(temp,z_file)) as z:
119 z.extractall(temp)
120 for x in os.listdir(temp):
121 if self.dd_name.lower() == x.lower():
122 # Found it
123 print(" - Found {}".format(x))
124 print(" - Copying to {} directory...".format(self.scripts))
125 shutil.copy(os.path.join(temp,x), os.path.join(self.s_path,x))
126 # Return to prior cwd
127 os.chdir(cwd)
128 # Remove the temp folder
129 shutil.rmtree(temp,ignore_errors=True)
130 print("")
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

Callers 1

mainMethod · 0.95

Calls 1

stream_to_fileMethod · 0.80

Tested by

no test coverage detected