Detection and setting of HOME environment variable for Open/LibreOffice to use #101

Open
wants to merge 7 commits into
from

Conversation

Projects
None yet
4 participants
@s0600204

When run, Unoconv now checks to see if the HOME environment variable is set and valid (i.e. exists and is writeable to). If neither of these things or if the user passes a '-H' argument, then Unoconv creates a temporary folder and sets that as HOME for the duration of the conversion, deleting it and its contents after use.

The user can also specify (with '--home=PATH') an alternate directory to use as HOME, and Unoconv will check that this is usable, defaulting to the user's HOME if not or a temporary folder if the user's HOME is not valid either.

As using a folder that has never been used before by Open/LibreOffice as HOME will cause Office to exit with code 81 (normal restart), Unoconv will catch this and try again. Unoconv will attempt to do this three times (four if you include the initial invocation) before giving up (to prevent an endless start-quit-start-quit cycle).

With any luck this should resolve issue #87. It certainly does for me. 馃槃 May also resolve issues 85 and 86.

Add option to specify HOME environment variable
Usage:
    --home=path

Example:
    unoconv --home=/var/tmp -f pdf some-file.odt

Note:
    If the user that calls unoconv does not have read/write access to the path given,
    unoconv will continue as if the argument had not been used.
@s0600204

This comment has been minimized.

Show comment Hide comment
@s0600204

s0600204 Oct 17, 2012

Owner

I should probably point out that this is my first attempt at coding in python, so apologies for any errors.

Owner

s0600204 commented on 8bb1e9a Oct 17, 2012

I should probably point out that this is my first attempt at coding in python, so apologies for any errors.

s0600204 added some commits Oct 24, 2012

Detect if default HOME is not suitable
 * Unoconv can now detect if the default environment variable HOME can not be read/written to.
 * In this case, unoconv creates a temporary directory using python's tempfile module and uses that instead.
 * A user may also trigger the use of a temporary file deliberately by using the '-H' option.

Note: For the time being, using a randomly generated folder causes *Office to returns a code of 81 and quit,
      preventing actual conversion. This is a known issue and will hopefully be addressed in a future commit.
Detection of exit code -81 during *Office listener init
 * Unoconv now detects exit code -81 (normal restart) during the initialisation of the *Office Listener and attempts to restart the listener.
 * As of this commit, Unoconv will restart *Office four (4) times before giving up, writing an error message.
    - This should prevent Unoconv and *Office from entering a perpetual restart-quit-restart cycle
 * This resolves the issue noted in my last commit. You should now be able to use a randomly generated or custom directory as HOME.
Add detection of no HOME value set in environment
 * If no HOME value is set in environment (ie. if the user uses "env -i"), the check determining whether the HOME folder was valid was failing, taking Unoconv with it.
 * This commit detects if there is no HOME environment value set and uses a temporary folder as HOME instead.

@s0600204 s0600204 referenced this pull request in OpenELEC/OpenELEC.tv Apr 15, 2013

Closed

Mount /var as tmpfs (not ramfs) and limit the use of tmpfs #2135

@s0600204 s0600204 referenced this pull request in oneye/oneye Jul 14, 2013

Closed

Office Update #15

@pataquets

This comment has been minimized.

Show comment Hide comment
@pataquets

pataquets Apr 10, 2015

Contributor

+1. This could save a lot of pain and is an easy solution.
Not to mention that the simple presence of the command line option alone could save lots of hair-pulling to people by hinting possible causes to obscure LO exit codes.

Contributor

pataquets commented Apr 10, 2015

+1. This could save a lot of pain and is an easy solution.
Not to mention that the simple presence of the command line option alone could save lots of hair-pulling to people by hinting possible causes to obscure LO exit codes.

@pataquets

This comment has been minimized.

Show comment Hide comment
@pataquets

pataquets Apr 10, 2015

+1. The verboser, the better.

+1. The verboser, the better.

@s0600204

This comment has been minimized.

Show comment Hide comment
@s0600204

s0600204 Jul 5, 2015

The problem this pull request was to resolve may or may not have been fixed in either d9810b7 or e4f65ed or both. Either way there are now merge conflicts, so I'm closing this request.

If, after testing, the problem still remains, I'll report back on #87.

s0600204 commented Jul 5, 2015

The problem this pull request was to resolve may or may not have been fixed in either d9810b7 or e4f65ed or both. Either way there are now merge conflicts, so I'm closing this request.

If, after testing, the problem still remains, I'll report back on #87.

@s0600204 s0600204 closed this Jul 5, 2015

@dagwieers dagwieers reopened this Jul 5, 2015

@dagwieers

This comment has been minimized.

Show comment Hide comment
@dagwieers

dagwieers Jul 5, 2015

Owner

I prefer to keep it open until we have decided how to implement it in #87, if you don't mind.

Owner

dagwieers commented Jul 5, 2015

I prefer to keep it open until we have decided how to implement it in #87, if you don't mind.

@s0600204

This comment has been minimized.

Show comment Hide comment
@s0600204

s0600204 Jul 5, 2015

That's absolutely fine, it's your project.

s0600204 commented Jul 5, 2015

That's absolutely fine, it's your project.

@dagwieers dagwieers added this to the Release 0.8 milestone Jul 5, 2015

@regebro regebro modified the milestones: Release 0.8, Release 0.9 Dec 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment