Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Windows support to the user profile parameter #558

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 16 additions & 1 deletion unoconv
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ def realpath(*args):
ret = os.path.join(ret, arg)
return os.path.realpath(os.path.abspath(ret))

# Formats a path into a file:// URL with support for Windows
def filepathURL(path):
# Linux style absolute path
if path.startswith("/"):
return "file://" + realpath(path)
# Windows style absolute path
else:
return "file:///" + realpath(path).replace("\\","/")




# The first thing we should do is find a suitable Office installation
# with a compatible pyuno library that we can import.
Expand Down Expand Up @@ -871,7 +882,7 @@ class Convertor:
else:
args = [office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nofirststartwizard", "--nologo", "--norestore", "--accept=%s" % op.connection]
if op.userProfile:
args.append("-env:UserInstallation=file://" + realpath(op.userProfile))
args.append("-env:UserInstallation="+filepathURL(op.userProfile))
info(2, '%s listener arguments are %s.' % (product.ooName, args))
ooproc = subprocess.Popen(args, env=os.environ)
info(2, '%s listener successfully started. (pid=%s)' % (product.ooName, ooproc.pid))
Expand Down Expand Up @@ -1238,6 +1249,10 @@ class Listener:
cmd = [office.binary, "-headless", "-invisible", "-nocrashreport", "-nodefault", "-nologo", "-nofirststartwizard", "-norestore", "-accept=%s" % op.connection]
else:
cmd = [office.binary, "--headless", "--invisible", "--nocrashreport", "--nodefault", "--nologo", "--nofirststartwizard", "--norestore", "--accept=%s" % op.connection]

if op.userProfile:
args.append("-env:UserInstallation="+filepathURL(op.userProfile))


# The rationale for using subprocess.Popen is to be able to handle
# a SIGTERM signal below and properly terminate the started office
Expand Down