Hello, is there a way to launch a p3d application (which uses some online packages) even if there is no internet connection (and, obviously, the user already has a local copy of those packages in his Panda cache)?
Now, if I launch my application (without internet connection and with the packages in the cache) I obtain this:
$ panda3d demo.p3d
:downloader: [0x999b30] begin GET [ http://www.../contents.xml?1300977905 ]
:downloader: [0x999b30] Could not connect to www...:80
:express(warning): error:2006A066:BIO routines:BIO_get_host_ip:bad hostname lookup
Error getting URL http://www.../contents.xml?1300977905
...
If the user does, in fact, already have these packages cached, it should run successfully anyway–the fallback is to launch the application if all of the needed files can be found in the local cache, and they are internally self-consistent.
In fact, the default behavior of the panda3d command-line program is not to even attempt to contact the server at all if the cache is self-consistent and not beyond its self-defined expiration time.
Since your question implies that the application did not launch, I infer that the user did not already have all of the packages.
Eh, did you say “self-defined expiration time”? Who can one setup this and what is the default value?
One can use locally stored packages with a “file:///C/etc/pp” and maybe there is a way to allow “flexible” paths too. Else the user could run it only from one predefined directory.
and it works. After that, I disconnect from internet, and I repeat:
$ panda3d app.p3d
but I obtain:
:downloader: [0x1a895f0] begin GET [ http://www.../contents.xml?1300983784 ]
:downloader: [0x1a895f0] Could not connect to www...:80
:express(warning): error:2006A066:BIO routines:BIO_get_host_ip:bad hostname lookup
Error getting URL http://www.../contents.xml?1300983784
XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":0.0"
after 36 requests (36 known processed) with 0 events remaining.
Ah, this appears to be a bug. My apologies; I’ll submit a fix. In the meantime, a workaround is to build your p3d from the same host that builds your package, for instance by defining it within the same pdef file like this:
# File: MyPackage.pdef
packager.setHost( 'http://www.myserver.org/path/to/packages' )
class MyPackage( package ):
dir( 'MyPackage' )
class app(p3d):
require('MyPackage', 'panda3d')
dir('.')
mainModule('main')
You can set packager.maxAge = 3600 (or some other time in seconds) in your pdef file. This will specify the expiration time of all packages offered by that host. This is only intended to reduce demand on the server; if the cache is newer than maxAge seconds, it won’t even contact the server. But it’s not necessary to make the code work in the absence of an internet connection, since that’s supposed to work anyway (once I fix the aforementioned bug).
Does this workaround snippet really work properly? Because when i tested creation of packages and p3d i had to run it twice or it need the data from an old run because the contents.xml is written after the complete run so it was missing during the first run (and just used the old contents.xml for every following run).
Right, that sounds like the way it’s supposed to work. You have to run it once, first, with an internet connection, so that it can download contents.xml and all of the package data into the cache.
Thereafter, it should run successfully without an internet connection, as long as the cache remains intact.
If you want to be able to run it without an internet connection the first time, you have to use pdeploy -s in installer mode, as rdb explained.
Well I am not really sure if I made my self clear. I have tried a similar approach like in the snippet but stumbled about the fact that the “class app(p3d):” part could only be done if the contents.xml already existed. But the contents.xml with the “MyPackage”-stuff only existed after the hole pdef was finished. So I had to split the package creation from my p3d creation and but them in 2 seperate pdef files. I will crosscheck this later. Maybe I just made an misstake.
I have no trouble running that pdef file the first time, before any packages have been built or uploaded. It generates a p3d file just fine. Can you tell me more about the specific problem you had?
Tried it again and had no problem this time. I guess that my old try lack the package.sethost call because if i remove it the “expected” behaviour showed up. So it maybe was just a fail of mine which I corrected unwitting while splitting the package and the p3d creation into two steps.