def _generate_ca(self): try: check_output_silent(shlex.split('openssl genrsa -out %s 1024' % self.ca_key)) args = shlex.split('openssl req -new -x509 -days %d -key %s -out %s -batch' \ % (self._expiration_days, self.ca_key, self.ca_cert)) check_output_silent(args) except subprocess.CalledProcessError as e: self.logger.error('openssl failed: %s' % e.output) return False return True
def _generate_key_and_cert_request(self, key_file, csr_file, common_name): try: check_output_silent(shlex.split('openssl genrsa -out %s 1024' % key_file)) args = shlex.split('openssl req -new -key %s -out %s -subj /CN=%s -config %s' % (key_file, csr_file, common_name, NuclideCertificatesGenerator.openssl_cnf)) check_output_silent(args, env=self._env) except subprocess.CalledProcessError as e: self.logger.error('openssl failed: %s' % e.output) return False return True
def _generate_certificate(self, csr_file, cert_file, serial): try: # Enable v3_req extensions. args = shlex.split('openssl x509 -req -days %d -in %s -CA %s -CAkey %s -set_serial %d -out %s -extensions v3_req -extfile %s' % (self._expiration_days, csr_file, self.ca_cert, self.ca_key, serial, cert_file, NuclideCertificatesGenerator.openssl_cnf)) check_output_silent(args, env=self._env) except subprocess.CalledProcessError as e: print('openssl failed: %s' % e.output, file=sys.stderr) return False return True
def stop(self): pid = self.get_pid() args = shlex.split('kill %s' % pid) try: # Stop existing Nuclide server. utils.check_output_silent(args) return 0 except subprocess.CalledProcessError as e: print('Failed to stop process %s: %s' % (pid, e.output), file=sys.stderr) return e.returncode
def _generate_key_and_cert_request(self, key_file, csr_file, common_name): try: check_output_silent(shlex.split('openssl genrsa -out %s 1024' % key_file)) args = shlex.split('openssl req -new -key %s -out %s -subj /CN=%s -config %s' % (key_file, csr_file, common_name, OPENSSL_CNF)) check_output_silent(args, env=self._env) except subprocess.CalledProcessError as e: print('openssl failed: %s' % e.output, file=sys.stderr) return False return True
def stop(self): pid = self.get_pid() args = shlex.split("kill %s" % pid) try: # Stop existing Nuclide server. utils.check_output_silent(args) return 0 except subprocess.CalledProcessError as e: self.logger.error("Failed to stop process %s: %s" % (pid, e.output)) return e.returncode
def stop(self): pid = self.get_pid() pgid = os.getpgid(int(pid)) # Use KILL signal to force the process group to quit. args = ['kill', '-9', '-%s' % pgid] try: # Stop existing Nuclide server. utils.check_output_silent(args) return 0 except subprocess.CalledProcessError as e: self.logger.error('Failed to stop process %s: %s' % (pid, e.output)) return e.returncode
def _generate_certificate(self, csr_file, cert_file, serial): try: # Enable v3_req extensions. args = shlex.split( 'openssl x509 -req -days %d -in %s -CA %s -CAkey %s -set_serial %d -out %s -extensions v3_req -extfile %s' % (self._expiration_days, csr_file, self.ca_cert, self.ca_key, serial, cert_file, NuclideCertificatesGenerator.openssl_cnf)) check_output_silent(args, env=self._env) except subprocess.CalledProcessError as e: self.logger.error('openssl failed: %s' % e.output) return False return True
def get_processes(user=None, regex_filter=None, columns=COLUMNS): args = ['ps', '-ww'] if columns is None: # If no column specified, we will get all columns. args.append('-f') else: # Filter out comm and command column and then append it to the end # so that we can use space as delimiter. new_columns = [column for column in columns if column not in ['comm', 'command']] new_columns.append('command') args.append('-o') args.append(','.join(columns)) if user is None: # List processes from all users. args.append('-A') else: args.append('-u') args.append(user) stdout = utils.check_output_silent(args) procs = [] for line in stdout.splitlines(): if regex_filter is not None and re.search(regex_filter, line) is None: continue procs.append(ProcessInfo(columns, line)) return procs
def get_processes(user=None, regex_filter=None, columns=COLUMNS): args = ['ps'] if columns is None: # If no column specified, we will get all columns. args.append('-f') else: # Filter out comm and command column and then append it to the end # so that we can use space as delimiter. new_columns = [ column for column in columns if column not in ['comm', 'command'] ] new_columns.append('command') args.append('-o') args.append(','.join(columns)) if user is None: # List processes from all users. args.append('-A') else: args.append('-u') args.append(user) stdout = utils.check_output_silent(args) procs = [] for line in stdout.splitlines(): if regex_filter is not None and re.search(regex_filter, line) is None: continue procs.append(ProcessInfo(columns, line)) return procs
def get_text(cert_file): return check_output_silent(shlex.split('openssl x509 -noout -text -in %s' % cert_file))
def get_text(cert_file): return check_output_silent( shlex.split('openssl x509 -noout -text -in %s' % cert_file))