mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 01:44:06 -04:00
find_host
This commit is contained in:
parent
6c6f498ebb
commit
10f5d804be
@ -19,6 +19,13 @@ from pandac.PandaModules import getModelPath, Filename, ConfigVariableFilename
|
|||||||
|
|
||||||
# Also see panda3d.pdef.
|
# Also see panda3d.pdef.
|
||||||
|
|
||||||
|
packager.setHost('file:///c:/cygwin/home/drose/p3dstage',
|
||||||
|
downloadUrl = 'file:///c:/cygwin/home/drose/p3dstage_1',
|
||||||
|
mirrors = ['file:///c:/cygwin/home/drose/mirror1',
|
||||||
|
'file:///c:/cygwin/home/drose/mirror2',
|
||||||
|
'http://www.ddrose.com/~drose/mirror3',
|
||||||
|
'http://www.ddrose.com/~drose/mirror4'])
|
||||||
|
|
||||||
class coreapi(solo):
|
class coreapi(solo):
|
||||||
# The special "coreapi" package. As a "solo", this is just a
|
# The special "coreapi" package. As a "solo", this is just a
|
||||||
# single .dll (or dylib, or whatever).
|
# single .dll (or dylib, or whatever).
|
||||||
|
@ -162,28 +162,7 @@ read_contents_file(const string &contents_filename) {
|
|||||||
if (xcontents != NULL) {
|
if (xcontents != NULL) {
|
||||||
// Look for the <host> entry; it might point us at a different
|
// Look for the <host> entry; it might point us at a different
|
||||||
// download URL, and it might mention some mirrors.
|
// download URL, and it might mention some mirrors.
|
||||||
string host_url = PANDA_PACKAGE_HOST_URL;
|
find_host(xcontents);
|
||||||
TiXmlElement *xhost = xcontents->FirstChildElement("host");
|
|
||||||
if (xhost != NULL) {
|
|
||||||
const char *url = xhost->Attribute("url");
|
|
||||||
if (url != NULL && host_url == string(url)) {
|
|
||||||
// We're the primary host. This is the normal case.
|
|
||||||
read_xhost(xhost);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// We're not the primary host; perhaps we're an alternate host.
|
|
||||||
TiXmlElement *xalthost = xhost->FirstChildElement("alt_host");
|
|
||||||
while (xalthost != NULL) {
|
|
||||||
const char *url = xalthost->Attribute("url");
|
|
||||||
if (url != NULL && host_url == string(url)) {
|
|
||||||
// Yep, we're this alternate host.
|
|
||||||
read_xhost(xhost);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
xalthost = xalthost->NextSiblingElement("alt_host");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now look for the core API package.
|
// Now look for the core API package.
|
||||||
TiXmlElement *xpackage = xcontents->FirstChildElement("package");
|
TiXmlElement *xpackage = xcontents->FirstChildElement("package");
|
||||||
@ -207,6 +186,43 @@ read_contents_file(const string &contents_filename) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: PPInstance::find_host
|
||||||
|
// Access: Private
|
||||||
|
// Description: Scans the <contents> element for the matching <host>
|
||||||
|
// element.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void PPInstance::
|
||||||
|
find_host(TiXmlElement *xcontents) {
|
||||||
|
string host_url = PANDA_PACKAGE_HOST_URL;
|
||||||
|
TiXmlElement *xhost = xcontents->FirstChildElement("host");
|
||||||
|
if (xhost != NULL) {
|
||||||
|
const char *url = xhost->Attribute("url");
|
||||||
|
if (url != NULL && host_url == string(url)) {
|
||||||
|
// We're the primary host. This is the normal case.
|
||||||
|
read_xhost(xhost);
|
||||||
|
return;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// We're not the primary host; perhaps we're an alternate host.
|
||||||
|
TiXmlElement *xalthost = xhost->FirstChildElement("alt_host");
|
||||||
|
while (xalthost != NULL) {
|
||||||
|
const char *url = xalthost->Attribute("url");
|
||||||
|
if (url != NULL && host_url == string(url)) {
|
||||||
|
// Yep, we're this alternate host.
|
||||||
|
read_xhost(xhost);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
xalthost = xalthost->NextSiblingElement("alt_host");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hmm, didn't find the URL we used mentioned. Assume we're the
|
||||||
|
// primary host.
|
||||||
|
read_xhost(xhost);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: PPInstance::read_xhost
|
// Function: PPInstance::read_xhost
|
||||||
// Access: Private
|
// Access: Private
|
||||||
|
@ -72,6 +72,7 @@ protected:
|
|||||||
int CopyFile( const std::string& from, const std::string& to );
|
int CopyFile( const std::string& from, const std::string& to );
|
||||||
|
|
||||||
bool read_contents_file(const std::string &contents_filename);
|
bool read_contents_file(const std::string &contents_filename);
|
||||||
|
void find_host(TiXmlElement *xcontents);
|
||||||
void read_xhost(TiXmlElement *xhost);
|
void read_xhost(TiXmlElement *xhost);
|
||||||
void add_mirror(std::string mirror_url);
|
void add_mirror(std::string mirror_url);
|
||||||
void choose_random_mirrors(std::vector<std::string> &result, int num_mirrors);
|
void choose_random_mirrors(std::vector<std::string> &result, int num_mirrors);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user