Blame dxf2gcode-0001-Add-support-for-system-wide-installation.patch

ff3caad
From 877409f09a91bf9714e2dee3bbb4d4337aaec966 Mon Sep 17 00:00:00 2001
ff3caad
From: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>
ff3caad
Date: Wed, 6 Sep 2017 20:08:18 +0200
ff3caad
Subject: [dxf2gcode PATCH 1/3] Add support for system wide installation
ff3caad
ff3caad
Detailed list of changes:
ff3caad
  - added python setuptools compatible installation script (st-setup.py),
ff3caad
  - added Desktop file (dxf2gcode.desktop),
ff3caad
  - added AppStream AppData metadata file (dxf2gcode.appdata.xml),
ff3caad
  - store configuration files in ~/.config/dxf2gcode directory (all platforms),
ff3caad
  - added support for disabling logginng to file by specifying empty ("") string,
ff3caad
  - disable, by default, logging to file (to avoid problems when running from read-only directories),
ff3caad
  - support for loading translation files from /usr/share/dxf2gcode/i18n directory.
ff3caad
ff3caad
Signed-off-by: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>
ff3caad
---
ff3caad
 source/MANIFEST.in           |  6 ++++
ff3caad
 source/dxf2gcode.appdata.xml | 41 ++++++++++++++++++++++
ff3caad
 source/dxf2gcode.desktop     | 10 ++++++
ff3caad
 source/dxf2gcode.py          | 13 ++++---
ff3caad
 source/globals/config.py     |  6 ++--
ff3caad
 source/st-setup.py           | 83 ++++++++++++++++++++++++++++++++++++++++++++
ff3caad
 6 files changed, 151 insertions(+), 8 deletions(-)
ff3caad
 create mode 100644 source/MANIFEST.in
ff3caad
 create mode 100644 source/dxf2gcode.appdata.xml
ff3caad
 create mode 100644 source/dxf2gcode.desktop
ff3caad
 create mode 100644 source/st-setup.py
ff3caad
ff3caad
diff --git a/source/MANIFEST.in b/source/MANIFEST.in
ff3caad
new file mode 100644
ff3caad
index 0000000..7152697
ff3caad
--- /dev/null
ff3caad
+++ b/source/MANIFEST.in
ff3caad
@@ -0,0 +1,6 @@
ff3caad
+include dxf2gcode.desktop
ff3caad
+include dxf2gcode.appdata.xml
ff3caad
+include images/dxf2gcode.svg
ff3caad
+include i18n/*.qm
ff3caad
+include COPYING
ff3caad
+
ff3caad
diff --git a/source/dxf2gcode.appdata.xml b/source/dxf2gcode.appdata.xml
ff3caad
new file mode 100644
ff3caad
index 0000000..b3dbb1e
ff3caad
--- /dev/null
ff3caad
+++ b/source/dxf2gcode.appdata.xml
ff3caad
@@ -0,0 +1,41 @@
ff3caad
+
ff3caad
+
ff3caad
+<component type="desktop">
ff3caad
+  <id>dxf2gcode.desktop</id>
ff3caad
+  <metadata_license>CC0-1.0</metadata_license>
ff3caad
+  <project_license>GPL-3.0+</project_license>
ff3caad
+  <name>dxf2gcode</name>
ff3caad
+  <summary>2D dxf drawings to CNC machine compatible G-Code converter</summary>
ff3caad
+  <description>
ff3caad
+    

ff3caad
+      dxf2gcode is a tool for converting 2D (dxf, pdf, ps) drawings to CNC machine compatible GCode.
ff3caad
+    

ff3caad
+
ff3caad
+    

Some features:

ff3caad
+      
    ff3caad
    +        
  • Integration in EMC2,
  • ff3caad
    +        
  • Fully adjustable Postprocessor,
  • ff3caad
    +        
  • G0 moves reduction by route optimisation,
  • ff3caad
    +        
  • Import of DXF and PDF,
  • ff3caad
    +        
  • Improved accuracy for splines import by Line and Arc's,
  • ff3caad
    +        
  • Mill parameter specifcation by layers,
  • ff3caad
    +        
  • Drag knife and lathe support,
  • ff3caad
    +        
  • Breaks a.k.a Tabs support,
  • ff3caad
    +        
  • AutoCAD Blocks and Inserts,
  • ff3caad
    +        
  • Multiple tools,
  • ff3caad
    +        
  • Multiple language support: english, german, french, russian,
  • ff3caad
    +        
  • 3D viewer.
  • ff3caad
    +      
    ff3caad
    +  </description>
    ff3caad
    +  <screenshots>
    ff3caad
    +    <screenshot type="default">
    ff3caad
    +      <image>https://a.fsdn.com/con/app/proj/dxf2gcode/screenshots/piede_20.png/1</image>
    ff3caad
    +    </screenshot>
    ff3caad
    +    <screenshot>
    ff3caad
    +      <image>https://a.fsdn.com/con/app/proj/dxf2gcode/screenshots/Frontplatte.png/1</image>
    ff3caad
    +    </screenshot>
    ff3caad
    +  </screenshots>
    ff3caad
    +  <url type="homepage">https://sourceforge.net/projects/dxf2gcode/</url>
    ff3caad
    +  <update_contact>dwrobel_at_ertelnet.rybnik.pl</update_contact>
    ff3caad
    +</component>
    ff3caad
    +
    ff3caad
    diff --git a/source/dxf2gcode.desktop b/source/dxf2gcode.desktop
    ff3caad
    new file mode 100644
    ff3caad
    index 0000000..9a08683
    ff3caad
    --- /dev/null
    ff3caad
    +++ b/source/dxf2gcode.desktop
    ff3caad
    @@ -0,0 +1,10 @@
    ff3caad
    +[Desktop Entry]
    ff3caad
    +Name=dxf2gcode converter
    ff3caad
    +Comment=2D dxf drawings to CNC machine compatible G-Code converter
    ff3caad
    +Exec=dxf2gcode %f
    ff3caad
    +Icon=dxf2gcode
    ff3caad
    +Keywords=cam;cnc;dxf;g-code
    ff3caad
    +Terminal=false
    ff3caad
    +StartupNotify=false
    ff3caad
    +Type=Application
    ff3caad
    +
    ff3caad
    diff --git a/source/dxf2gcode.py b/source/dxf2gcode.py
    ff3caad
    index 52b2ac5..5698a91 100644
    ff3caad
    --- a/source/dxf2gcode.py
    ff3caad
    +++ b/source/dxf2gcode.py
    ff3caad
    @@ -76,10 +76,7 @@ else:
    ff3caad
     
    ff3caad
     logger = logging.getLogger()
    ff3caad
     
    ff3caad
    -# Get folder of the main instance and write into globals
    ff3caad
    -g.folder = os.path.dirname(os.path.abspath(sys.argv[0])).replace("\\", "/")
    ff3caad
    -if os.path.islink(sys.argv[0]):
    ff3caad
    -    g.folder = os.path.dirname(os.readlink(sys.argv[0]))
    ff3caad
    +g.folder = os.path.join(os.path.expanduser("~"), ".config/dxf2gcode").replace("\\", "/")
    ff3caad
     
    ff3caad
     
    ff3caad
     class MainWindow(QMainWindow):
    ff3caad
    @@ -1086,7 +1083,11 @@ if __name__ == "__main__":
    ff3caad
     
    ff3caad
         g.config = MyConfig()
    ff3caad
         Log.set_console_handler_loglevel()
    ff3caad
    -    Log.add_file_logger()
    ff3caad
    +
    ff3caad
    +    if not g.config.vars.Logging['logfile']:
    ff3caad
    +        Log.add_window_logger()
    ff3caad
    +    else:
    ff3caad
    +        Log.add_file_logger()
    ff3caad
     
    ff3caad
         app = QApplication(sys.argv)
    ff3caad
     
    ff3caad
    @@ -1096,6 +1097,8 @@ if __name__ == "__main__":
    ff3caad
         translator = QtCore.QTranslator()
    ff3caad
         if translator.load("dxf2gcode_" + locale, "./i18n"):
    ff3caad
             app.installTranslator(translator)
    ff3caad
    +    elif translator.load("dxf2gcode_" + locale, "/usr/share/dxf2gcode/i18n"):
    ff3caad
    +        app.installTranslator(translator)
    ff3caad
     
    ff3caad
         # If string version_mismatch isn't empty, we popup an error and exit
    ff3caad
         if g.config.version_mismatch:
    ff3caad
    diff --git a/source/globals/config.py b/source/globals/config.py
    ff3caad
    index 1c04932..e395e22 100644
    ff3caad
    --- a/source/globals/config.py
    ff3caad
    +++ b/source/globals/config.py
    ff3caad
    @@ -275,8 +275,8 @@ CONFIG_SPEC = str('''
    ff3caad
         gcode = string(default = "(change subsection name and insert your custom GCode here. Use triple quote to place the code on several lines)")
    ff3caad
     
    ff3caad
         [Logging]
    ff3caad
    -    # Logging to textfile is enabled automatically for now
    ff3caad
    -    logfile = string(default = "logfile.txt")
    ff3caad
    +    # Logging to textfile is disabled by default
    ff3caad
    +    logfile = string(default = "")
    ff3caad
     
    ff3caad
         # This really goes to stderr
    ff3caad
         console_loglevel = option('DEBUG', 'INFO', 'WARNING', 'ERROR','CRITICAL', default = 'CRITICAL')
    ff3caad
    @@ -351,7 +351,7 @@ class MyConfig(object):
    ff3caad
         def make_settings_folder(self):
    ff3caad
             """Create settings folder if necessary"""
    ff3caad
             try:
    ff3caad
    -            os.mkdir(self.folder)
    ff3caad
    +            os.makedirs(self.folder)
    ff3caad
             except OSError:
    ff3caad
                 pass
    ff3caad
     
    ff3caad
    diff --git a/source/st-setup.py b/source/st-setup.py
    ff3caad
    new file mode 100644
    ff3caad
    index 0000000..1269931
    ff3caad
    --- /dev/null
    ff3caad
    +++ b/source/st-setup.py
    ff3caad
    @@ -0,0 +1,83 @@
    ff3caad
    +############################################################################
    ff3caad
    +#
    ff3caad
    +#   Copyright (C) 2017
    ff3caad
    +#    Damian Wrobel <dwrobel@ertelnet.rybnil.pl>
    ff3caad
    +#
    ff3caad
    +#   This file is part of DXF2GCODE.
    ff3caad
    +#
    ff3caad
    +#   DXF2GCODE is free software: you can redistribute it and/or modify
    ff3caad
    +#   it under the terms of the GNU General Public License as published by
    ff3caad
    +#   the Free Software Foundation, either version 3 of the License, or
    ff3caad
    +#   (at your option) any later version.
    ff3caad
    +#
    ff3caad
    +#   DXF2GCODE is distributed in the hope that it will be useful,
    ff3caad
    +#   but WITHOUT ANY WARRANTY; without even the implied warranty of
    ff3caad
    +#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    ff3caad
    +#   GNU General Public License for more details.
    ff3caad
    +#
    ff3caad
    +#   You should have received a copy of the GNU General Public License
    ff3caad
    +#   along with DXF2GCODE.  If not, see <http://www.gnu.org/licenses/>.
    ff3caad
    +#
    ff3caad
    +############################################################################
    ff3caad
    +
    ff3caad
    +from setuptools import setup
    ff3caad
    +import glob
    ff3caad
    +
    ff3caad
    +import distutils.command.install_scripts
    ff3caad
    +import shutil
    ff3caad
    +
    ff3caad
    +class install_scripts(distutils.command.install_scripts.install_scripts):
    ff3caad
    +    def run(self):
    ff3caad
    +        distutils.command.install_scripts.install_scripts.run(self)
    ff3caad
    +        for script in self.get_outputs():
    ff3caad
    +            if script.endswith(".py"):
    ff3caad
    +                shutil.move(script, script[:-3])
    ff3caad
    +
    ff3caad
    +setup(
    ff3caad
    +    name='dxf2gcode',
    ff3caad
    +
    ff3caad
    +    version='20170503',
    ff3caad
    +
    ff3caad
    +    description='2D drawings to CNC machine compatible G-Code converter.',
    ff3caad
    +
    ff3caad
    +    long_description=('DXF2GCODE is a tool for converting 2D (dxf, pdf, ps)'
    ff3caad
    +                      ' drawings to CNC machine compatible GCode.'),
    ff3caad
    +
    ff3caad
    +    url='https://sourceforge.net/p/dxf2gcode/wiki/Home/',
    ff3caad
    +
    ff3caad
    +    author='Christian Kohloffel',
    ff3caad
    +
    ff3caad
    +    license='GPLv3',
    ff3caad
    +
    ff3caad
    +    packages=[
    ff3caad
    +        'core',
    ff3caad
    +        'dxfimport',
    ff3caad
    +        'globals',
    ff3caad
    +        'globals.configobj',
    ff3caad
    +        'gui',
    ff3caad
    +        'postpro'
    ff3caad
    +    ],
    ff3caad
    +
    ff3caad
    +    py_modules=[
    ff3caad
    +        "dxf2gcode_images5_rc",
    ff3caad
    +        "dxf2gcode_ui5"
    ff3caad
    +    ],
    ff3caad
    +
    ff3caad
    +    install_requires=[
    ff3caad
    +        'PyQt5',
    ff3caad
    +        'PyOpenGL'
    ff3caad
    +    ],
    ff3caad
    +
    ff3caad
    +    include_package_data=True,
    ff3caad
    +
    ff3caad
    +    data_files=[
    ff3caad
    +        ('share/appdata', ['dxf2gcode.appdata.xml']),
    ff3caad
    +        ('share/applications', ['dxf2gcode.desktop']),
    ff3caad
    +        ('share/dxf2gcode/i18n', glob.glob('i18n/*.qm')),
    ff3caad
    +        ('share/icons/hicolor/scalable/apps/', ['images/dxf2gcode.svg'])
    ff3caad
    +    ],
    ff3caad
    +
    ff3caad
    +    cmdclass = {"install_scripts": install_scripts},
    ff3caad
    +
    ff3caad
    +    scripts=['dxf2gcode.py']
    ff3caad
    +)
    ff3caad
    -- 
    ff3caad
    2.9.5
    ff3caad