How to use the qtpyvcp.utilities.logger function in qtpyvcp

To help you get started, we’ve selected a few qtpyvcp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kcjengr / qtpyvcp / qtpyvcp / widgets / dialogs / open_file_dialog.py View on Github external
#!/usr/bin/env python

import os
import sys


from qtpy import QtCore
from qtpy.QtGui import QIcon
from qtpy.QtCore import Qt
from qtpy.QtWidgets import QMessageBox, QFileDialog

from qtpyvcp.utilities import logger
LOG = logger.getLogger(__name__)

from qtpyvcp.core import Info
INFO = Info()

from qtpyvcp.actions.program_actions import load as loadProgram

class _OpenFileDialog(QFileDialog):
    """docstring for OpenFileDialog"""
    def __init__(self, parent=None):
        super(_OpenFileDialog, self).__init__(parent)

        nc_file_dir = INFO.getProgramPrefix()
        nc_file_types = INFO.getQtFilefilter()

        self.setDirectory(nc_file_dir)
        self.setNameFilters(nc_file_types.split(';;'))
github kcjengr / qtpyvcp / qtpyvcp / utilities / obj_status.py View on Github external
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see .

import linuxcnc, time, threading, subprocess, os, json
from qtpy.QtCore import QObject, QTimer, Signal

# Setup logging
try:
    from qtpyvcp.utilities import logger
    log = logger.getLogger(__name__)
    log.setLevel('WARNING')
except Exception as e:
    print e
    import logging as log
    FORMAT = "[%(levelname)s]: %(message)s (%(filename)s:%(lineno)d)"
    log.basicConfig(level=log.DEBUG, format=FORMAT)


#==============================================================================
# Status Monitor
#==============================================================================

class StatusItem(QObject):
    """docstring for StatusItem"""

    valueChanged = Signal('PyQt_PyObject')
github kcjengr / qtpyvcp / qtpyvcp / utilities / prefs.py View on Github external
get("section", "option", "default_val", type)
   dro_places = get("DROs", "dec_places", 3, int)

"""

import os
import ast

import ConfigParser

from qtpyvcp.utilities.info import Info
from qtpyvcp.utilities.misc import normalizePath

# Set up logging
from qtpyvcp.utilities import logger
log = logger.getLogger(__name__)

INFO = Info()
CONFIG_DIR = os.getenv('CONFIG_DIR')

class _Preferences(ConfigParser.RawConfigParser):

    def __init__(self, pref_file='~/.qtpyvcp.pref'):
        ConfigParser.RawConfigParser.__init__(self)

        self.pref_file = normalizePath(pref_file, CONFIG_DIR) or '/dev/null'

        self.getters = {
            bool: self.getBool,
            float: self.getFloat,
            int: self.getInt,
            list: self.getList,
github kcjengr / qtpyvcp / qtpyvcp / widgets / display_widgets / dro_widget.py View on Github external
def __init__(self, parent=None):
        super(DROWidget, self).__init__(parent)

        self.log = logger.getLogger(__name__)

        self._axis_number = Axis.X
        self._ref_typ = RefType.Absolute

        self._metric_format = '%10.3f'
        self._imperial_format = '%9.4f'

        units = INIFILE.find("TRAJ", "LINEAR_UNITS") or "inch"
        if units == 'inch':
            self._format = self._imperial_format
        else:
            self._format = self._metric_format

        self.update(getattr(POSITION, RefType.toString(self._ref_typ)).getValue())
        STATUS.program_units.notify(self.onUnitsChanged, 'string')
github kcjengr / qtpyvcp / qtpyvcp / actions / __init__.py View on Github external
import os
import sys
from qtpy.QtWidgets import QAction, QPushButton, QCheckBox, QSlider, QSpinBox, QComboBox, QDial

import machine_actions as machine
import program_actions as program
import spindle_actions as spindle
import coolant_actions as coolant
import tool_actions as tool

# Set up logging
from qtpyvcp.utilities import logger
LOG = logger.getLogger(__name__)

IN_DESIGNER = os.getenv('DESIGNER', False)

class InvalidAction(Exception):
    pass

def bindWidget(widget, action):
    """Binds a widget to an action.

    Args:
        widget (QWidget) : The widget to bind the action too. Typically `widget`
            is a QPushButton, QCheckBox, QComboBox, QSlider or QAction instance.

        action (str) : The string identifier of the action to bind the widget
            to, in the format ``action_class.action_name:arg1, arg2 ...``.
github kcjengr / qtpyvcp / qtpyvcp / widgets / hal_widgets / hal_led_widget.py View on Github external
from qtpy.QtCore import Slot, Property

from qtpyvcp.widgets.base_widgets.led_widget import LEDWidget
from qtpyvcp.utilities.obj_status import HALStatus

# Setup logging
from qtpyvcp.utilities import logger
log = logger.getLogger(__name__)


class HalLedWidget(LEDWidget):

    # one to rule them all
    hal_status = HALStatus()

    def __init__(self, parent=None):
        super(HalLedWidget, self).__init__(parent)

        self._hal_pin = ''

    def getHalPin(self):
        return self._hal_pin

    @Slot(str)
github kcjengr / qtpyvcp / qtpyvcp / utilities / opt_parser.py View on Github external
os.getenv('HOME'))

    if log_file is None or os.path.isdir(log_file):
        log_file = os.path.expanduser('~/qtpyvcp.log')

    opts.log_file = log_file

    # init the logger
    from qtpyvcp.utilities import logger
    LOG = logger.initBaseLogger('qtpyvcp',
                                log_file=opts.log_file,
                                log_level=opts.log_level or "INFO")

    LOG.info("QtPyVCP Version: %s", QTPYVCP_VERSION)

    if LOG.getEffectiveLevel() == logger.logLevelFromName("DEBUG"):
        import qtpy
        LOG.debug("Qt Version: %s", qtpy.QT_VERSION)
        LOG.debug("Qt API: %s", qtpy.QT_API)
        LOG.debug("QtPy Version: %s", qtpy.__version__)


        LOG.debug("Command line options:\n%s",
                  json.dumps(opts, sort_keys=True, indent=4))

    return opts
github kcjengr / qtpyvcp / qtpyvcp / utilities / action.py View on Github external
#   You should have received a copy of the GNU General Public License
#   along with QtPyVCP.  If not, see .

# Description:
#   Collection of linuxcnc.command convenience functions.
#   Incomplete

import time
import linuxcnc

from qtpy.QtCore import QTimer, Slot
from qtpy.QtWidgets import QAction, QPushButton

# Set up logging
from qtpyvcp.utilities import logger
LOG = logger.getLogger(__name__)

from qtpyvcp.utilities.info import Info
from qtpyvcp.utilities.status import Status
INFO = Info()
STATUS = Status()
STAT = STATUS.stat

CMD = linuxcnc.command()


class Action(object):
    """Ensures only one instance of StatusPoller exists per python interpretor.
    """
    _instance = None
    def __new__(cls, *args, **kwargs):
        if not cls._instance:
github kcjengr / qtpyvcp / qtpyvcp / widgets / base_widgets / dro_base_widget.py View on Github external
DROBaseWidget
-------------

"""

from qtpy.QtCore import Slot, Property

from qtpyvcp.plugins import getPlugin
from qtpyvcp.utilities.settings import getSetting

from qtpyvcp.widgets import VCPWidget
from qtpyvcp.utilities import logger

from qtpyvcp.utilities.info import Info

LOG = logger.getLogger(__name__)
INFO = Info()

class Axis(object):
    ALL = -1
    X, Y, Z, A, B, C, U, V, W = range(9)


class Units(object):
    Program = 0  # Use program units
    Inch = 1     # CANON_UNITS_INCHES=1
    Metric = 2   # CANON_UNITS_MM=2


class RefType(object):
    Absolute = 0
    Relative = 1
github kcjengr / qtpyvcp / qtpyvcp / widgets / form_widgets / main_window.py View on Github external
from qtpy import uic
from qtpy.QtGui import QKeySequence
from qtpy.QtCore import Qt, Slot, QTimer
from qtpy.QtWidgets import QMainWindow, QApplication, QAction, QMessageBox, \
    QMenu, QMenuBar, QLineEdit, QShortcut

import qtpyvcp
from qtpyvcp import actions
from qtpyvcp.utilities import logger
from qtpyvcp.utilities.info import Info
from qtpyvcp.plugins import getPlugin
from qtpyvcp.widgets.dialogs import showDialog as _showDialog
from qtpyvcp.app.launcher import _initialize_object_from_dict

LOG = logger.getLogger(__name__)
INFO = Info()


class VCPMainWindow(QMainWindow):

    def __init__(self, parent=None, opts=None, ui_file=None, stylesheet=None,
                 maximize=False, fullscreen=False, position=None, size=None,
                 confirm_exit=True, title=None, menu='default'):

        super(VCPMainWindow, self).__init__(parent)

        if opts is None:
            opts = qtpyvcp.OPTIONS

        self.setWindowTitle(title)