Skip to content

Commit

Permalink
fix log file location cross platform, fix #37,fix #54
Browse files Browse the repository at this point in the history
  • Loading branch information
berteh committed Aug 10, 2016
1 parent 89e18a8 commit 97c2453
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 28 deletions.
29 changes: 8 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ A [short *how to* video](https://www.youtube.com/watch/kMsRn38TOiQ) introduces t



[Download](https://github.com/berteh/ScribusGenerator/archive/master.zip) the script and uncompress it anywhere on the local machine. It can be placed with the standard extension scripts. On Windows platform this location would be ``SCRIBUS_INSTALL_DIRECTORY\share\scripts\``, on Ubuntu ``/usr/share/scribus/scripts/``. We recommand to make this directory writeable to your user, to allow the loging of Scribus Generator actions, or see the [configuration](#run-the-generator-script-settings) section to move the loging file elsewhere.
[Download](https://github.com/berteh/ScribusGenerator/archive/master.zip) the script and uncompress it anywhere on the local machine. It can be placed with the standard extension scripts. On Windows platform this location would be ``SCRIBUS_INSTALL_DIRECTORY\share\scripts\``, on Ubuntu ``/usr/share/scribus/scripts/``.

**Scribus Generator** can then be started by choosing the script (``ScribusGenerator.py``) within the dialog: _«Scribus → Script → Execute Script»_, or from the [command line](#running-scribus-generator-from-the-command-line). It is implemented as a Python script.
**Scribus Generator** can then be started by choosing the script (``ScribusGenerator.py``) within the dialog: _«Scribus → Script → Execute Script»_, or from the [command line](#running-scribus-generator-from-the-command-line).



Expand Down Expand Up @@ -167,18 +167,12 @@ To change the properties of a sub-element (such as one particular text line in a

Running Scribus Generator from the command line
---------
It is possible to run Scribus Generator from the command line. Great to automate your workflow or integrate with other tools!
It is possible to run Scribus Generator from the command line, and it's fast! Great to automate your workflow or integrate with other tools.

Note only the SLA generation works from the command line. PDF generation is at the moment impossible from the Scribus Generator command line due to Scribus 1.4 limitations.
Please note only the SLA generation works from the command line. PDF generation is at the moment not suppoted from the Scribus Generator command line.

Find all needed information from the script help: ``./ScribusGeneratorCLI.py --help``

###WARNING!

- The short option for a *single output* has changed to ``-m`` (merge). The former ``-s`` option is now used to *save* your settings from the command line, as explained below.
- All pdf-related options (--fast, --noPdf, --pdfOnly, --noSla) have been removed from Scribus Generator CLI v2, as the CLI can only generate SLA files.


```
positional arguments:
infiles SLA file(s) to use as template(s) for the generation,
Expand Down Expand Up @@ -259,9 +253,9 @@ If you want to keep these unused variables and empty texts, simply change the de

### Logging and debug

ScribusGenerator records all its actions in a log file located (by default) in its own directory. If you encounter an unexpected behaviour check out the content of scribusGenerator.log to find out more. You can change the logging settings in logging.conf (see [Python log configuration](https://docs.python.org/2/howto/logging.html#configuring-logging) for more options).
ScribusGenerator records all its actions in a log file located (by default) in your user (home) directory. If you encounter an unexpected behaviour check out the content of ```.scribusGenerator.log``` to find out more. You can change the logging settings in logging.conf (see [Python log configuration](https://docs.python.org/2/howto/logging.html#configuring-logging) for more options).

Kindly copy-paste the relevant (usually last) lines of your scribusGenerator.log if you want to [report an issue](https://github.com/berteh/ScribusGenerator/issues).
Kindly copy-paste the relevant (usually last) lines of your ```.scribusGenerator.log``` if you want to [report an issue](https://github.com/berteh/ScribusGenerator/issues).

### Variable Names

Expand Down Expand Up @@ -296,14 +290,6 @@ You can use ```sqlite3 -csv``` in command line or ```.mode csv``` in sqlite's in

Known Issues
-------
### Nothing happens

> I get the script GUI and press 'generate' and nothing happens.
Is the directory of Scribus Generator writeable? It needs to be so we can record (log) all actions of the script. Simply move the whole Scribus Generator directory to a directory that does not need admin rights (such as your desktop) and try again. If that works you can simply consider changing the location of the logging file (see [configuration](#run-the-generator-script-settings) ), and move the script back where it belongs.

If that is still not enough, kindly report an [issue](https://github.com/berteh/ScribusGenerator/issues) online, and copy there the few last lines of your log file (it's ```scribusGenerator.log```, inside your Scribus Generator plugin directory) to help find the reason of this bad behaviour, along with a short explanation of your problem.

### Mac OSX troubleshooting

Some install of Python on Mac OSX do not ship a working Tkinter package, that is required for ScribusGenerator GUI. Either find a way to setup a compliant TCL/Tk environment, or simply use the [Scribus Generator command line interface](#running-scribus-generator-from-the-command-line).
Expand All @@ -312,7 +298,8 @@ If you would like to contribute another GUI to Scribus Generator that works in M

Support
--------
Check out the [wiki](https://github.com/berteh/ScribusGenerator/wiki) for more ideas, look at the [solved](https://github.com/berteh/ScribusGenerator/issues?q=is%3Aissue+is%3Aclosed) and [open issues](https://github.com/berteh/ScribusGenerator/issues), and then report a new issue if you have a problem.
Check out the [wiki](https://github.com/berteh/ScribusGenerator/wiki) for more ideas, look at the [solved](https://github.com/berteh/ScribusGenerator/issues?q=is%3Aissue+is%3Aclosed) and [open issues](https://github.com/berteh/ScribusGenerator/issues), and then kindly report an [issue](https://github.com/berteh/ScribusGenerator/issues) online, and copy there the few last lines of your log file (it's ```.scribusGenerator.log```, inside your user (home) directory, to help find the reason of this bad behaviour, along with a short explanation of your problem.


Licence
--------
Expand Down
1 change: 1 addition & 0 deletions ScribusGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# For further information (manual, description, etc.) please visit:
# https://github.com/berteh/ScribusGenerator/
#
# v2.2 (2016-08-10): various bug fix (logging location in windows, dynamic colors in Scribus 1.5.2 and some more)
# v2.0 (2015-12-02): added features (merge, range, clean, save/load)
# v1.9 (2015-08-03): initial command-line support (SLA only, use GUI version to generate PDF)
# v1.1 (2014-10-01): Add support for overwriting attributes from data (eg text/area color)
Expand Down
9 changes: 4 additions & 5 deletions ScribusGeneratorBackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# For further information (manual, description, etc.) please visit:
# https://github.com/berteh/ScribusGenerator/
#
# v2.2 (2016-08-10): various bug fix (logging location in windows, dynamic colors in Scribus 1.5.2 and some more)
# v2.0 (2015-12-02): added features (merge, range, clean, save/load)
# v1.9 (2015-08-03): initial command-line support (SLA only, use GUI version to generate PDF)
# v1.1 (2014-10-01): Add support for overwriting attributes from data (eg text/area color)
Expand Down Expand Up @@ -54,10 +55,8 @@ class ScribusGenerator:
def __init__(self, dataObject):
self.__dataObject = dataObject
logging.config.fileConfig(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'logging.conf'))
# root_logger = logging.getLogger()
# root_logger.disabled = True
# todo: check if logging works, if not warn user to configure log file path and disable.
logging.debug("ScribusGenerator initialized")
logging.info("ScribusGenerator initialized")


def run(self):
Expand All @@ -69,7 +68,7 @@ def run(self):
self.__dataObject.setOutputFileName(os.path.split(os.path.splitext(self.__dataObject.getScribusSourceFile())[0])[1] +'__single')

#parsing
logging.debug("parsing data source file %s"%(self.__dataObject.getDataSourceFile()))
logging.info("parsing data source file %s"%(self.__dataObject.getDataSourceFile()))
csvData = self.getCsvData(self.__dataObject.getDataSourceFile())
if(len(csvData) < 1):
logging.error("Data file %s is empty. At least a header line and a line of data is needed. Halting."%(self.__dataObject.getDataSourceFile()))
Expand Down Expand Up @@ -107,7 +106,7 @@ def run(self):
if(index == 0): # first line is the Header-Row of the CSV-File
varNamesForFileName = row
varNamesForReplacingVariables = self.handleAmpersand(row) # Header-Row contains the variable names
logging.debug("parsing scribus source file %s"%(self.__dataObject.getScribusSourceFile()))
logging.info("parsing scribus source file %s"%(self.__dataObject.getScribusSourceFile()))
tree = ET.parse(self.__dataObject.getScribusSourceFile())
root = tree.getroot()
# overwrite attributes from their /*/ItemAttribute[Type=SGAttribute] sibling, when applicable.
Expand Down
4 changes: 2 additions & 2 deletions logging.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ formatter=simple

[handler_file]
class=handlers.RotatingFileHandler
args=('scribusGenerator.log','a','maxBytes=1000','backupCount=1')
args=(os.path.expanduser('~/.scribusGenerator.log'),'a','maxBytes=50','backupCount=1')
formatter=full

[formatter_simple]
format=%(asctime)s - ScribusGenerator - %(levelname)s: %(message)s
datefmt=%H:%M:%S

[formatter_full]
format=%(asctime)s - %(name)s - %(levelname)s - %(funcName)s:%(lineno)d - %(message)s
format=%(asctime)s - %(levelname)s - %(funcName)s:%(lineno)d - %(message)s
datefmt=%Y-%m-%d %H:%M:%S

0 comments on commit 97c2453

Please sign in to comment.