Пример #1
0
 def setUp(self):
     super(RulesTest, self).setUp()
     good_data_path = os.path.join(TEST_PATH,
                                   'less_compliant_smbios_records.txt')
     good_data_file = resources.GetResourceFilename(good_data_path)
     bad_data_path = os.path.join(TEST_PATH,
                                  'not_less_compliant_smbios_records.txt')
     bad_data_file = resources.GetResourceFilename(bad_data_path)
     self.good_records, self.good_groups = dmiparse.DmiParser(
         good_data_file).parse()
     self.bad_records, self.bad_groups = dmiparse.DmiParser(
         bad_data_file).parse()
Пример #2
0
 def setUp(self):
     super(MatcherTest, self).setUp()
     data_path = os.path.join(TEST_PATH,
                              'less_compliant_smbios_records.txt')
     data_file = resources.GetResourceFilename(data_path)
     self.records, _ = dmiparse.DmiParser(data_file).parse()
     self.assertLen(self.records, 294)
Пример #3
0
    def where():
        """Return the preferred certificate bundle."""
        # MOE:begin_strip
        try:
            if resources is not None:
                # Load from resources so that it works for .par files.
                return resources.GetResourceFilename(
                    'google3/third_party/py/requests/cacert.pem')
        except IOError:
            pass

        # vendored bundle inside Requests
        # MOE:end_strip
        return os.path.join(os.path.dirname(__file__), 'cacert.pem')
Пример #4
0
    def start(self):
        assert self._handle is None

        try:
            from google3.pyglib import resources
            executable = resources.GetResourceFilename(
                "google3/third_party/py/grpc/sync_server")
            args = [executable, '--host_and_port', self._host_and_port]
        except ImportError:
            executable = sys.executable
            directory, _ = os.path.split(os.path.abspath(__file__))
            filename = directory + '/sync_server.py'
            args = [
                executable, filename, '--host_and_port', self._host_and_port
            ]

        self._handle = subprocess.Popen(args)
Пример #5
0
def get():
    """Locate the ca_certs.txt file.

  The httplib2 library will look for local ca_certs_locater module to override
  the default location for the ca_certs.txt file. We override it here to first
  try loading via pyglib.resources, falling back to the traditional method if
  that fails.

  Returns:
    The file location returned as a string.
  """
    try:
        ca_certs = resources.GetResourceFilename(
            'google3/third_party/py/httplib2/cacerts.txt')
    except (IOError, AttributeError):
        # We're either running in an environment where we don't have access to
        # google3.pyglib.resources, or an environment where it won't work correctly
        # (e.g., //apphosting/tools:dev_appserver_internal_main). In either of these
        # cases, we fall back on the os.path.join approach.
        ca_certs = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                'cacerts.txt')
    return ca_certs
 def setUp(self):
     super(DmiParserTest, self).setUp()
     data_path = os.path.join(TEST_PATH,
                              'less_compliant_smbios_records.txt')
     self.data_file = resources.GetResourceFilename(data_path)