def download_metrics_json(self):
        url = urljoin(self.config.graphite_url_server, "metrics/index.json")
        if self.config.graphite_username is not None and self.config.graphite_password is not None:
            username = self.config.graphite_username
            password = self.config.graphite_password
            passmanager = urllib2.HTTPPasswordMgrWithDefaultRealm()
            passmanager.add_password(None, url, username, password)
            authhandler = urllib2.HTTPBasicAuthHandler(passmanager)
            opener = urllib2.build_opener(authhandler)
            urllib2.install_opener(opener)

        response = urllib2.urlopen(url)

        with open('%s.tmp' % self.config.filename_metrics, 'w') as m:
            m.write(response.read())
        try:
            os.unlink(self.config.filename_metrics)
        except OSError:
            pass
        os.rename('%s.tmp' % self.config.filename_metrics, self.config.filename_metrics)
dataset/ETHPy150Open vimeo/graph-explorer/graph_explorer/backend.py/Backend.download_metrics_json/original