re-order version and platform in filenames, again

This commit is contained in:
David Rose 2009-08-24 19:39:04 +00:00
parent bfb948c5a8
commit f39222cd1d
6 changed files with 56 additions and 50 deletions

View File

@ -12,7 +12,7 @@ class PackageInfo:
self.packageVersion = packageVersion self.packageVersion = packageVersion
self.platform = platform self.platform = platform
self.packageFullname = '%s_%s' % (self.packageName, self.packageVersion) self.packageFullname = '%s.%s' % (self.packageName, self.packageVersion)
self.packageDir = Filename(host.hostDir, 'packages/%s/%s' % (self.packageName, self.packageVersion)) self.packageDir = Filename(host.hostDir, 'packages/%s/%s' % (self.packageName, self.packageVersion))
self.descFileBasename = self.packageFullname + '.xml' self.descFileBasename = self.packageFullname + '.xml'

View File

@ -257,13 +257,12 @@ class Packager:
if platformSpecific and not self.platform: if platformSpecific and not self.platform:
self.platform = PandaSystem.getPlatform() self.platform = PandaSystem.getPlatform()
if not self.p3dApplication and self.platform and not self.version: if not self.p3dApplication and not self.version:
# We must have a version string for platform-specific # If we don't have an implicit version, inherit the
# packages. Use the first versioned string on our # version from the 'panda3d' package on our require
# require list. # list.
self.version = 'base'
for p2 in self.requires: for p2 in self.requires:
if p2.version: if p2.packageName == 'panda3d' and p2.version:
self.version = p2.version self.version = p2.version
break break
@ -420,15 +419,15 @@ class Packager:
self.packageBasename = self.packageName self.packageBasename = self.packageName
packageDir = self.packageName packageDir = self.packageName
if self.platform:
self.packageBasename += '_' + self.platform
packageDir += '/' + self.platform
if self.version: if self.version:
self.packageBasename += '_' + self.version self.packageBasename += '.' + self.version
packageDir += '/' + self.version packageDir += '/' + self.version
if self.platform:
self.packageBasename += '.' + self.platform
packageDir += '/' + self.platform
self.packageDesc = self.packageBasename + '.xml' self.packageDesc = self.packageBasename + '.xml'
self.packageImportDesc = self.packageBasename + '_import.xml' self.packageImportDesc = self.packageBasename + '.import.xml'
if self.p3dApplication: if self.p3dApplication:
self.packageBasename += '.p3d' self.packageBasename += '.p3d'
packageDir = '' packageDir = ''
@ -917,7 +916,7 @@ class Packager:
xpackage.SetAttribute(variable, str(value)) xpackage.SetAttribute(variable, str(value))
def writeImportDescFile(self): def writeImportDescFile(self):
""" Makes the package_import.xml file that describes the """ Makes the package.import.xml file that describes the
package and its contents, for other packages and package and its contents, for other packages and
applications that may wish to "require" this one. """ applications that may wish to "require" this one. """
@ -1635,7 +1634,7 @@ class Packager:
def __scanPackageDir(self, rootDir, packageName, platform, version, def __scanPackageDir(self, rootDir, packageName, platform, version,
host, requires = None): host, requires = None):
""" Scans a directory on disk, looking for *_import.xml files """ Scans a directory on disk, looking for *.import.xml files
that match the indicated packageName and optional version. If a that match the indicated packageName and optional version. If a
suitable xml file is found, reads it and returns the assocated suitable xml file is found, reads it and returns the assocated
Package definition. Package definition.
@ -1648,23 +1647,23 @@ class Packager:
packageDir = Filename(rootDir, packageName) packageDir = Filename(rootDir, packageName)
basename = packageName basename = packageName
if platform:
packageDir = Filename(packageDir, platform)
basename += '_%s' % (platform)
if version: if version:
# A specific version package. # A specific version package.
packageDir = Filename(packageDir, version) packageDir = Filename(packageDir, version)
basename += '_%s' % (version) basename += '.%s' % (version)
else: else:
# Scan all versions. # Scan all versions.
packageDir = Filename(packageDir, '*') packageDir = Filename(packageDir, '*')
basename += '_%s' % ('*') basename += '.%s' % ('*')
if platform:
packageDir = Filename(packageDir, platform)
basename += '.%s' % (platform)
# Actually, the host means little for this search, since we're # Actually, the host means little for this search, since we're
# only looking in a local directory at this point. # only looking in a local directory at this point.
basename += '_import.xml' basename += '.import.xml'
filename = Filename(packageDir, basename) filename = Filename(packageDir, basename)
filelist = glob.glob(filename.toOsSpecific()) filelist = glob.glob(filename.toOsSpecific())
if not filelist: if not filelist:
@ -1673,9 +1672,13 @@ class Packager:
filename = Filename(rootDir, basename) filename = Filename(rootDir, basename)
filelist = glob.glob(filename.toOsSpecific()) filelist = glob.glob(filename.toOsSpecific())
self.__sortPackageImportFilelist(filelist) packages = []
for file in filelist: for file in filelist:
package = self.__readPackageImportDescFile(Filename.fromOsSpecific(file)) package = self.__readPackageImportDescFile(Filename.fromOsSpecific(file))
packages.append(package)
self.__sortImportPackages(packages)
for package in packages:
if package and self.__packageIsValid(package, requires): if package and self.__packageIsValid(package, requires):
return package return package
@ -1709,15 +1712,14 @@ class Packager:
if package.readImportDescFile(filename): if package.readImportDescFile(filename):
return package return package
def __sortPackageImportFilelist(self, filelist): def __sortImportPackages(self, packages):
""" Given a list of *_import.xml filenames, sorts them in """ Given a list of Packages read from *.import.xml filenames,
reverse order by version, so that the highest-numbered sorts them in reverse order by version, so that the
versions appear first in the list. """ highest-numbered versions appear first in the list. """
tuples = [] tuples = []
for file in filelist: for package in packages:
version = file.split('_')[-2] version = self.__makeVersionTuple(package.version)
version = self.__makeVersionTuple(version)
tuples.append((version, file)) tuples.append((version, file))
tuples.sort(reverse = True) tuples.sort(reverse = True)

View File

@ -124,6 +124,7 @@ def makePackedApp(args):
packager.do_mainModule(mainModule) packager.do_mainModule(mainModule)
packager.endPackage() packager.endPackage()
packager.close()
except Packager.PackagerError: except Packager.PackagerError:
# Just print the error message and exit gracefully. # Just print the error message and exit gracefully.

View File

@ -319,18 +319,19 @@ paint_window() {
bar_x, bar_y, bar_width, bar_height); bar_x, bar_y, bar_width, bar_height);
if (_install_progress != 0.0) { if (_install_progress != 0.0) {
int progress_width = (int)((bar_width - 2) * _install_progress);
int progress = bar_x + 1 + progress_width;
Rect rbar = { bar_y, bar_x, bar_y + bar_height, bar_x + bar_width }; Rect rbar = { bar_y, bar_x, bar_y + bar_height, bar_x + bar_width };
Rect rneed = { bar_y + 1, progress, bar_y + bar_height - 1, bar_x + bar_width - 1 };
Rect rdone = { bar_y + 1, bar_x + 1, bar_y + bar_height - 1, progress };
FrameRect(&rbar); FrameRect(&rbar);
RGBColor blue = { 27756, 42405, 57568 }; int progress_width = (int)((bar_width - 2) * _install_progress);
RGBForeColor(&blue); if (progress_width != 0) {
PaintRect(&rdone); int progress = bar_x + 1 + progress_width;
EraseRect(&rneed); Rect rneed = { bar_y + 1, progress, bar_y + bar_height - 1, bar_x + bar_width - 1 };
Rect rdone = { bar_y + 1, bar_x + 1, bar_y + bar_height - 1, progress };
RGBColor blue = { 27756, 42405, 57568 };
RGBForeColor(&blue);
PaintRect(&rdone);
EraseRect(&rneed);
}
RGBColor black = { 0, 0, 0 }; RGBColor black = { 0, 0, 0 };
RGBForeColor(&black); RGBForeColor(&black);

View File

@ -46,7 +46,7 @@ P3DPackage(P3DHost *host, const string &package_name,
_package_dir = _host->get_host_dir() + string("/") + _package_name; _package_dir = _host->get_host_dir() + string("/") + _package_name;
if (!_package_version.empty()) { if (!_package_version.empty()) {
_package_fullname += string("_") + _package_version; _package_fullname += string(".") + _package_version;
_package_dir += string("/") + _package_version; _package_dir += string("/") + _package_version;
} }
@ -275,6 +275,9 @@ download_desc_file() {
// locally. Adjust desc_file to point to the local file. // locally. Adjust desc_file to point to the local file.
string url_filename = desc_file.get_filename(); string url_filename = desc_file.get_filename();
_desc_file_url = _host->get_host_url_prefix();
_desc_file_url += url_filename;
_desc_file_basename = url_filename; _desc_file_basename = url_filename;
size_t slash = _desc_file_basename.rfind('/'); size_t slash = _desc_file_basename.rfind('/');
if (slash != string::npos) { if (slash != string::npos) {
@ -302,10 +305,7 @@ download_desc_file() {
} }
// The desc file is not current. Go download it. // The desc file is not current. Go download it.
string url = _host->get_host_url_prefix(); start_download(DT_desc_file, _desc_file_url, _desc_file_pathname, false);
url += url_filename;
start_download(DT_desc_file, url, _desc_file_pathname, false);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -466,13 +466,14 @@ begin_data_download() {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void P3DPackage:: void P3DPackage::
download_compressed_archive(bool allow_partial) { download_compressed_archive(bool allow_partial) {
string url = _host->get_host_url_prefix(); string url = _desc_file_url;
url += _package_name; size_t slash = url.rfind('/');
if (!_package_platform.empty()) { if (slash != string::npos) {
url += "/" + _package_platform; url = url.substr(0, slash + 1);
} }
url += "/" + _package_version; url += _compressed_archive.get_filename();
url += "/" + _compressed_archive.get_filename(); cerr << "_desc_file_url = " << _desc_file_url << ", url = " << url
<< "\n";
string target_pathname = _package_dir + "/" + _compressed_archive.get_filename(); string target_pathname = _package_dir + "/" + _compressed_archive.get_filename();

View File

@ -121,6 +121,7 @@ private:
P3DTemporaryFile *_temp_contents_file; P3DTemporaryFile *_temp_contents_file;
string _desc_file_url;
string _desc_file_basename; string _desc_file_basename;
string _desc_file_pathname; string _desc_file_pathname;