def Checkout(self): Cprint('[pacman] installing %s ' % self.name, 'purple') rc = subprocess.call('sudo pacman -S %s' % self.target, shell=True) if rc != 0: return Cprint( '[error] pacman failed to installing %s, error: %s' % (self.target, rc), 'red') return self.AfterCheckout()
def Add(self, component, check=True): if check: if not component.name.islower(): Cprint('[warn] modules names should be lower case: ' + component.name, 'yellow') # Its possible that a component is tried to be added twice because a new # dependency was downloaded and if component.name not in self: self[component.name] = component return component else: Cprint('[warn] component tried to be re-added %s' % component.name, 'red')
def _CreateDependency(env, name, type, node, target=None, dep_type=DEP_PROJECT): if target is None: target = os.path.join(env['WS_DIR'], name) if type == 'DEP': return Dependencies(name, target, node, env) elif type == 'HG': return HG(name, target, node, env) elif type == 'SVN': return SVN(name, target, node, env) elif type == 'WGET': return WGET(name, target, node, env) elif type == 'APTITUDE': return APTITUDE(name, target, node, env) elif type == 'APT-GET': return APT_GET(name, target, node, env) elif type == 'PACMAN': return PACMAN(name, target, node, env) elif type == 'PACKER': return PACKER(name, target, node, env) else: Cprint( '[error] %s %s has repository %s which is not supported' % (dep_type, name, type), 'red') return None
def Update(self): Cprint('[hg] updating %s => %s' % (self.url, self.target), 'purple') rc = subprocess.call("cd %s; hg pull -u" % self.target, shell=True) if rc != 0: return Cformat( '[error] hg failed to update target %s from %s, error: %s' % (self.target, self.url, rc), 'red') return 0
def Checkout(self): if not os.path.exists(self.target): os.makedirs(self.target) Cprint('[hg] Checkout %s => %s' % (self.url, self.target), 'purple') rc = subprocess.call(['hg', 'clone', self.url, self.target]) if rc != 0: return Cformat( '[error] hg failed to Checkout target %s from %s, error: %s' % (self.target, self.url, rc), 'red') return self.AfterCheckout()
def Checkout(self): if not os.path.exists(self.target): os.makedirs(self.target) Cprint('[wget] downloading %s => %s' % (self.url, self.target), 'purple') rc = subprocess.call(['wget', self.url, '-P', self.target]) if rc != 0: return Cformat( '[error] wget failed to download target %s from %s, error: %s' % (self.target, self.url, rc), 'red') return self.AfterCheckout()
def _astyle_check_action(target, source, env): '''This prepares the environment for _astyle_check_diff to run''' # Get the report file. report_file = target[0].abspath # Get the output directory. output_directory = os.path.split(report_file)[0] # Check if the directory exists. if not source: raise StopError('[ERROR] No source files to check') if not os.path.exists(output_directory): os.makedirs(output_directory) # Check if some file need astyle. check_astyle_result = _get_astyle_diff(env, source, output_directory) # Check if _get_astyle_diff() fails. if check_astyle_result is None: raise StopError('[ERROR] Failed running Astyle Check.') # Open the report file. try: report = open(report_file, 'w') except IOError: raise StopError('[ERROR] No such file or directory.') else: # If we can open it we truncate it. report.truncate(0) # If some file needs astyle we print info. if check_astyle_result: # Print a warning message. Cprint('[WARNING] The following files need astyle:', 'yellow') # Print what need to be astyled. for f, info in check_astyle_result: # Write into hte report file. report.write(info + '\n\n') # Print on the screen. Cprint('====> %s' % f, 'yellow') Cprint(info, 'yellow') else: Cprint('[OK] No file needs astyle.', 'green') # Close the report file. report.close() return os.EX_OK
def Checkout(self): if not os.path.exists(self.target): os.makedirs(self.target) Cprint('[svn] Checkout %s => %s' % (self.url, self.target), 'purple') cmd = ['svn', 'checkout' ] + (['--username', self.username] if self.username else []) + [self.url, self.target] rc = subprocess.call(cmd) if rc != 0: return Cformat( '[error] svn failed to checkout target %s from %s, error: %s' % (self.target, self.url, rc), 'red') return self.AfterCheckout()
def AfterCheckout(self): """ Description: This method download the component/project and install it. Arguments: None. Exceptions: None. Return: True if the component is installed. False otherwise. """ if len(self.executeAfter) > 0: commands = _GetExecutableCommands(self.env, self.executeAfter) for cmd in commands: Cprint('[info] execute post-checkout command: %s' % cmd, 'purple') rc = subprocess.call(cmd, shell=True) if rc != 0: return Cformat( '[error] failed to execute post-checkout command: %s, error: %s' % (cmd, rc), 'red') return 0