Merge pull request #10 from andkit/master
Update portable version to set a suitable default location for settings file
This commit is contained in:
commit
34a690c713
@ -6,11 +6,15 @@ How to create a new portable Windows distribution of OpenSlides:
|
|||||||
|
|
||||||
easy_install -Z django django-mptt reportlab pil
|
easy_install -Z django django-mptt reportlab pil
|
||||||
|
|
||||||
2.) In the main directory of the OpenSlides checkout execute:
|
2.) Install OpenSlides by running python setup.py install in the top directory
|
||||||
|
of OpenSlides.
|
||||||
|
NOTE: This step must be repeated whenever you make changes to OpenSlides
|
||||||
|
|
||||||
|
3.) In the main directory of the OpenSlides checkout execute:
|
||||||
|
|
||||||
python extras/win32-portable/prepare_portable.py
|
python extras/win32-portable/prepare_portable.py
|
||||||
|
|
||||||
3.) The portable OpenSlides distribution is now ready as a zip in the
|
4.) The portable OpenSlides distribution is now ready as a zip in the
|
||||||
'dist/' directory
|
'dist/' directory
|
||||||
|
|
||||||
Note: Creating the portable Windows distribution of OpenSlides is not possible,
|
Note: Creating the portable Windows distribution of OpenSlides is not possible,
|
||||||
|
@ -23,7 +23,7 @@ static const char *site_code =
|
|||||||
|
|
||||||
static const char *run_openslides_code =
|
static const char *run_openslides_code =
|
||||||
"import openslides.main;"
|
"import openslides.main;"
|
||||||
"openslides.main.main()";
|
"openslides.main.win32_portable_main()";
|
||||||
|
|
||||||
/* determine the path to the executable
|
/* determine the path to the executable
|
||||||
* NOTE: Py_GetFullProgramPath() can't be used because
|
* NOTE: Py_GetFullProgramPath() can't be used because
|
||||||
|
Binary file not shown.
@ -45,10 +45,6 @@ LIBEXCLUDE = [
|
|||||||
r"^unittest/",
|
r"^unittest/",
|
||||||
]
|
]
|
||||||
|
|
||||||
OPENSLIDES_EXCLUDE = [
|
|
||||||
r"^openslides/settings.py"
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
SITE_PACKAGES = {
|
SITE_PACKAGES = {
|
||||||
"django": {
|
"django": {
|
||||||
@ -84,7 +80,10 @@ SITE_PACKAGES = {
|
|||||||
"pil": {
|
"pil": {
|
||||||
# NOTE: PIL is a special case, see copy_pil
|
# NOTE: PIL is a special case, see copy_pil
|
||||||
"copy": [],
|
"copy": [],
|
||||||
}
|
},
|
||||||
|
"openslides": {
|
||||||
|
"copy" : ["openslides"],
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
PY_DLLS = [
|
PY_DLLS = [
|
||||||
@ -302,9 +301,6 @@ def main():
|
|||||||
collect_lib(libdir, odir)
|
collect_lib(libdir, odir)
|
||||||
collect_site_packages(sitedir, os.path.join(odir, "site-packages"))
|
collect_site_packages(sitedir, os.path.join(odir, "site-packages"))
|
||||||
|
|
||||||
exclude = get_pkg_exclude("openslides", OPENSLIDES_EXCLUDE)
|
|
||||||
copy_dir_exclude(exclude, ".", "openslides", odir)
|
|
||||||
|
|
||||||
if not compile_openslides_launcher():
|
if not compile_openslides_launcher():
|
||||||
sys.stdout.write("Using prebuild openslides.exe\n")
|
sys.stdout.write("Using prebuild openslides.exe\n")
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ def _fs2unicode(s):
|
|||||||
return s.decode(_fs_encoding)
|
return s.decode(_fs_encoding)
|
||||||
|
|
||||||
|
|
||||||
def main(argv=None):
|
def main(argv=None, opt_defaults=None):
|
||||||
if argv is None:
|
if argv is None:
|
||||||
argv = sys.argv[1:]
|
argv = sys.argv[1:]
|
||||||
|
|
||||||
@ -90,6 +90,9 @@ def main(argv=None):
|
|||||||
parser.add_option(
|
parser.add_option(
|
||||||
"--no-reload", action="store_true", help="Do not reload the development server")
|
"--no-reload", action="store_true", help="Do not reload the development server")
|
||||||
|
|
||||||
|
if not opt_defaults is None:
|
||||||
|
parser.set_defaults(**opt_defaults)
|
||||||
|
|
||||||
opts, args = parser.parse_args(argv)
|
opts, args = parser.parse_args(argv)
|
||||||
if args:
|
if args:
|
||||||
sys.stderr.write("This command does not take arguments!\n\n")
|
sys.stderr.write("This command does not take arguments!\n\n")
|
||||||
@ -249,6 +252,47 @@ def start_browser(url):
|
|||||||
t = threading.Thread(target=f)
|
t = threading.Thread(target=f)
|
||||||
t.start()
|
t.start()
|
||||||
|
|
||||||
|
def win32_portable_main(argv=None):
|
||||||
|
"""special entry point for the win32 portable version"""
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
# NOTE: sys.executable will be the path to openslides.exe
|
||||||
|
# since it is essentially a small wrapper that embeds the
|
||||||
|
# python interpreter
|
||||||
|
portable_dir = os.path.dirname(os.path.abspath(sys.executable))
|
||||||
|
try:
|
||||||
|
fd, test_file = tempfile.mkstemp(dir=portable_dir)
|
||||||
|
except OSError:
|
||||||
|
portable_dir_writeable = False
|
||||||
|
else:
|
||||||
|
portable_dir_writeable = True
|
||||||
|
os.close(fd)
|
||||||
|
os.unlink(test_file)
|
||||||
|
|
||||||
|
if portable_dir_writeable:
|
||||||
|
default_settings = os.path.join(portable_dir, "openslides",
|
||||||
|
"openslides_personal_settings.py")
|
||||||
|
else:
|
||||||
|
import ctypes
|
||||||
|
|
||||||
|
shell32 = ctypes.WinDLL("shell32.dll")
|
||||||
|
SHGetFolderPath = shell32.SHGetFolderPathW
|
||||||
|
SHGetFolderPath.argtypes = (ctypes.c_void_p, ctypes.c_int,
|
||||||
|
ctypes.c_void_p, ctypes.c_uint32, ctypes.c_wchar_p)
|
||||||
|
SHGetFolderPath.restype = ctypes.c_uint32
|
||||||
|
|
||||||
|
CSIDL_LOCAL_APPDATA = 0x001c
|
||||||
|
MAX_PATH = 260
|
||||||
|
|
||||||
|
buf = ctypes.create_unicode_buffer(MAX_PATH)
|
||||||
|
res = SHGetFolderPath(0, CSIDL_LOCAL_APPDATA, 0, 0, buf)
|
||||||
|
if res != 0:
|
||||||
|
raise Exception("Could not deterime APPDATA path")
|
||||||
|
default_settings = os.path.join(buf.value, "openslides",
|
||||||
|
"openslides_personal_settings.py")
|
||||||
|
|
||||||
|
main(argv, opt_defaults={ "settings": default_settings })
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user