Browse Source

some fixes

David Rose 16 years ago
parent
commit
e7daad7dce

+ 2 - 0
direct/src/plugin/p3dInstance.cxx

@@ -1236,6 +1236,8 @@ report_package_progress(P3DPackage *package, double progress) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void P3DInstance::
 void P3DInstance::
 report_package_done(P3DPackage *package, bool success) {
 report_package_done(P3DPackage *package, bool success) {
+  nout << "Done downloading " << package->get_package_name()
+       << ": success = " << success << "\n";
   if (success) {
   if (success) {
     report_package_progress(package, 1.0);
     report_package_progress(package, 1.0);
     start_next_download();
     start_next_download();

+ 19 - 5
direct/src/plugin/p3dPackage.cxx

@@ -231,7 +231,7 @@ download_desc_file() {
   // Attempt to check the desc file for freshness.  If it already
   // Attempt to check the desc file for freshness.  If it already
   // exists, and is consistent with the server contents file, we don't
   // exists, and is consistent with the server contents file, we don't
   // need to re-download it.
   // need to re-download it.
-  string root_dir = inst_mgr->get_root_dir();
+  string root_dir = inst_mgr->get_root_dir() + "/packages";
   FileSpec desc_file;
   FileSpec desc_file;
   if (!inst_mgr->get_package_desc_file(desc_file, _package_name, _package_version)) {
   if (!inst_mgr->get_package_desc_file(desc_file, _package_name, _package_version)) {
     nout << "Couldn't find package " << _package_fullname
     nout << "Couldn't find package " << _package_fullname
@@ -242,7 +242,7 @@ download_desc_file() {
          << desc_file.get_pathname(root_dir) 
          << desc_file.get_pathname(root_dir) 
          << " instead of " << _desc_file_pathname << "\n";
          << " instead of " << _desc_file_pathname << "\n";
 
 
-  } else if (!desc_file.quick_verify(root_dir)) {
+  } else if (!desc_file.full_verify(root_dir)) {
     nout << _desc_file_pathname << " is stale.\n";
     nout << _desc_file_pathname << " is stale.\n";
 
 
   } else {
   } else {
@@ -337,6 +337,7 @@ got_desc_file(TiXmlDocument *doc, bool freshly_downloaded) {
   Extracts::iterator ci;
   Extracts::iterator ci;
   for (ci = _extracts.begin(); ci != _extracts.end(); ++ci) {
   for (ci = _extracts.begin(); ci != _extracts.end(); ++ci) {
     if (!(*ci).quick_verify(_package_dir)) {
     if (!(*ci).quick_verify(_package_dir)) {
+      nout << "File is incorrect: " << (*ci).get_filename() << "\n";
       all_extracts_ok = false;
       all_extracts_ok = false;
       break;
       break;
     }
     }
@@ -664,9 +665,22 @@ report_done(bool success) {
     _failed = true;
     _failed = true;
   }
   }
 
 
-  Instances::iterator ii;
-  for (ii = _instances.begin(); ii != _instances.end(); ++ii) {
-    (*ii)->report_package_done(this, success);
+  if (!_allow_data_download && success) {
+    // If we haven't been authorized to start downloading yet, just
+    // report that we're ready to start, but that we don't have to
+    // download anything.
+    _download_size = 0;
+    Instances::iterator ii;
+    for (ii = _instances.begin(); ii != _instances.end(); ++ii) {
+      (*ii)->report_package_info_ready(this);
+    }
+
+  } else {
+    // Otherwise, we can report that we're fully downloaded.
+    Instances::iterator ii;
+    for (ii = _instances.begin(); ii != _instances.end(); ++ii) {
+      (*ii)->report_package_done(this, success);
+    }
   }
   }
 }
 }
 
 

+ 14 - 4
direct/src/plugin_standalone/panda3d.cxx

@@ -325,12 +325,22 @@ get_plugin(const string &download_url, const string &this_platform, bool force_d
   
   
   HTTPClient *http = HTTPClient::get_global_ptr();
   HTTPClient *http = HTTPClient::get_global_ptr();
   PT(HTTPChannel) channel = http->get_document(url);
   PT(HTTPChannel) channel = http->get_document(url);
-  contents_filename.make_dir();
-  if (!channel->download_to_file(contents_filename)) {
+
+  // First, download it to a temporary file.
+  Filename tempfile = Filename::temporary("", "p3d_");
+  if (!channel->download_to_file(tempfile)) {
     cerr << "Unable to download " << url << "\n";
     cerr << "Unable to download " << url << "\n";
-    return false;
+    tempfile.unlink();
+
+    // Couldn't download, but fall through and try to read the
+    // contents.xml file anyway.  Maybe it's good enough.
+  } else {
+    // Successfully downloaded; move the temporary file into place.
+    contents_filename.make_dir();
+    contents_filename.unlink();
+    tempfile.rename_to(contents_filename);
   }
   }
-  
+
   return read_contents_file(contents_filename, download_url, this_platform);
   return read_contents_file(contents_filename, download_url, this_platform);
 }
 }
 
 

+ 30 - 1
direct/src/showutil/FreezeTool.py

@@ -11,6 +11,7 @@ from distutils.sysconfig import PREFIX, get_python_inc, get_python_version
 
 
 import direct
 import direct
 from pandac.PandaModules import *
 from pandac.PandaModules import *
+from pandac.extension_native_helpers import dll_suffix, dll_ext
 
 
 # Check to see if we are running python_d, which implies we have a
 # Check to see if we are running python_d, which implies we have a
 # debug build, and we have to build the module with debug options.
 # debug build, and we have to build the module with debug options.
@@ -654,7 +655,7 @@ class Freezer:
                 excludes.append(mdef.moduleName)
                 excludes.append(mdef.moduleName)
                 excludeDict[mdef.moduleName] = token
                 excludeDict[mdef.moduleName] = token
 
 
-        self.mf = modulefinder.ModuleFinder(excludes = excludes)
+        self.mf = PandaModuleFinder(excludes = excludes)
 
 
         # Attempt to import the explicit modules into the modulefinder.
         # Attempt to import the explicit modules into the modulefinder.
         for mdef in includes:
         for mdef in includes:
@@ -1148,3 +1149,31 @@ class Freezer:
             return False
             return False
 
 
         return True
         return True
+
+class PandaModuleFinder(modulefinder.ModuleFinder):
+    """ We subclass ModuleFinder here, to add functionality for
+    finding the libpandaexpress etc. modules that interrogate
+    produces. """
+
+    def find_module(self, name, path, parent=None):
+        try:
+            return modulefinder.ModuleFinder.find_module(self, name, path, parent = parent)
+        except ImportError:
+            # It wasn't found.  Maybe it's one of ours.
+            if path:
+                # Only if we're not looking on a particular path,
+                # though.
+                raise
+
+        # This loop is roughly lifted from
+        # extension_native_helpers.Dtool_PreloadDLL().
+        filename = name + dll_suffix + dll_ext
+        for dir in sys.path + [sys.prefix]:
+            lib = os.path.join(dir, filename)
+            if os.path.exists(lib):
+                file = open(lib, 'rb')
+                return (file, lib, (dll_ext, 'rb', 3))
+
+        message = "DLL loader cannot find %s." % (name)
+        raise ImportError, message
+        

+ 8 - 1
direct/src/showutil/Packager.py

@@ -325,6 +325,13 @@ class Packager:
                 # Don't bother, it's already here.
                 # Don't bother, it's already here.
                 return
                 return
 
 
+            if file.newName in self.targetFilenames:
+                # Another file is already in the same place.
+                file2 = self.targetFilenames[file.newName]
+                self.packager.notify.warning(
+                    "%s is shadowing %s" % (file2.filename, file.filename))
+                return
+
             self.sourceFilenames[file.filename] = file
             self.sourceFilenames[file.filename] = file
 
 
             if not file.filename.exists():
             if not file.filename.exists():
@@ -1035,7 +1042,7 @@ class Packager:
             'dciman32.dll', 'comdlg32.dll', 'comctl32.dll', 'ole32.dll',
             'dciman32.dll', 'comdlg32.dll', 'comctl32.dll', 'ole32.dll',
             'oleaut32.dll', 'gdiplus.dll', 'winmm.dll',
             'oleaut32.dll', 'gdiplus.dll', 'winmm.dll',
 
 
-            'libSystem.B.dylib', 'libmathCommon.A.dylib', 'libmx.A.dylib',
+            'libsystem.b.dylib', 'libmathcommon.a.dylib', 'libmx.a.dylib',
             'libstdc++.6.dylib',
             'libstdc++.6.dylib',
             ]
             ]
 
 

+ 2 - 2
direct/src/showutil/runp3d.py

@@ -22,7 +22,7 @@ See pack3d.py for a script that generates these p3d files.
 import sys
 import sys
 from direct.showbase import VFSImporter
 from direct.showbase import VFSImporter
 from direct.showbase.DirectObject import DirectObject
 from direct.showbase.DirectObject import DirectObject
-from pandac.PandaModules import VirtualFileSystem, Filename, Multifile, loadPrcFileData, unloadPrcFile, getModelPath, HTTPClient, Thread, WindowProperties, readXmlStream
+from pandac.PandaModules import VirtualFileSystem, Filename, Multifile, loadPrcFileData, unloadPrcFile, getModelPath, HTTPClient, Thread, WindowProperties, readXmlStream, ExecutionEnvironment
 from direct.stdpy import file
 from direct.stdpy import file
 from direct.task.TaskManagerGlobal import taskMgr
 from direct.task.TaskManagerGlobal import taskMgr
 from direct.showbase.MessengerGlobal import messenger
 from direct.showbase.MessengerGlobal import messenger
@@ -291,7 +291,7 @@ class AppRunner(DirectObject):
         if self.p3dPackage:
         if self.p3dPackage:
             fullDiskAccess = self.p3dPackage.Attribute('full_disk_access')
             fullDiskAccess = self.p3dPackage.Attribute('full_disk_access')
             try:
             try:
-                self.fullDiskAccess = int(fullDiskAccess)
+                self.fullDiskAccess = int(fullDiskAccess or '')
             except ValueError:
             except ValueError:
                 pass
                 pass