コード例 #1
0
 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
コード例 #2
0
 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
コード例 #3
0
 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
コード例 #4
0
ファイル: process_info.py プロジェクト: dalinaum/nuclide
 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
コード例 #5
0
 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
コード例 #6
0
ファイル: process_info.py プロジェクト: rugby110/nuclide
 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
コード例 #7
0
 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
コード例 #8
0
ファイル: process_info.py プロジェクト: JoelMarcey/nuclide
 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
コード例 #9
0
 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
コード例 #10
0
ファイル: process_info.py プロジェクト: errazudin/nuclide
 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
コード例 #11
0
ファイル: process_info.py プロジェクト: JoelMarcey/nuclide
    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
コード例 #12
0
    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
コード例 #13
0
 def get_text(cert_file):
     return check_output_silent(shlex.split('openssl x509 -noout -text -in %s' % cert_file))
コード例 #14
0
 def get_text(cert_file):
     return check_output_silent(
         shlex.split('openssl x509 -noout -text -in %s' % cert_file))