Skip to content

Commit

Permalink
Add tclk/simple codegen (#1022)
Browse files Browse the repository at this point in the history
* Add initial metadata

* Create nitclk.mak

* Remove numpy restriction

Bug fixed

* Upgrade pip

* Remove specific version of flake8

'\' in comments now need to be escaped

* Add basepython section

* Try using pypy3.5

* Go back to pypy3 and remove basepython block

* Don't need to run build_test for all builds - only 3.6

* Remove warning from coverage

* Undo previous change

* Try disabling faulthandler

* Remove --no-faulthandler

* pypy needs an older version of pytest

See pytest-dev/pytest#5807

* Use platform_python_implementation since implementation_name is not defined on Python2

* Try to get back to the initial coverage

* Do the same thing for build_test

* Remove redundant pip

* Add codecov file to try to control limits for passing

* Enable nitclk build

* There are some files we will need to skip for now

* Add generated nitclk files

* Update generated files

* Can't skip README.rst

* Force change

* Update generated files

* Update generated files
  • Loading branch information
texasaggie97-zz authored and marcoskirsch committed Sep 6, 2019
1 parent 55e9e97 commit 5de4716
Show file tree
Hide file tree
Showing 19 changed files with 2,819 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# In alphabetical order except put nifake first and nimodinst last
# In alphabetical order except put nifake first and nimodinst/nitclk last
# - nifake first to get the most code generator coverage
# - nimodinst last so that the version from nimodinst is used for any global versions (docs/conf.py)
ALL_DRIVERS := nifake nidcpower nidigital nidmm nifgen niscope niswitch nise nimodinst
ALL_DRIVERS := nifake nidcpower nidigital nidmm nifgen niscope niswitch nise nimodinst nitclk
DRIVERS ?= $(ALL_DRIVERS)

ROOT_DIR := $(abspath .)
Expand Down
41 changes: 41 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,47 @@ NI-SWITCH Python API Status
:target: https://github.com/ni/nimi-python/pulls?q=is%3Aopen+is%3Aissue+label%3Aniswitch



NI-TClk Python API Status
-------------------------

+-------------------------------+-----------------------+
| NI-TClk (nitclk) | |
+===============================+=======================+
| Driver Version Tested Against | 18.0.0 |
+-------------------------------+-----------------------+
| Driver API Version | 255.0.0d0 |
+-------------------------------+-----------------------+
| PyPI Version | |nitclkLatestVersion| |
+-------------------------------+-----------------------+
| Supported Python Version | |nitclkPythonVersion| |
+-------------------------------+-----------------------+
| Open Issues | |nitclkOpenIssues| |
+-------------------------------+-----------------------+
| Open Pull Requests | |nitclkOpenPRs| |
+-------------------------------+-----------------------+


.. |nitclkLatestVersion| image:: http://img.shields.io/pypi/v/nitclk.svg
:alt: Latest NI-TClk Version
:target: http://pypi.python.org/pypi/nitclk


.. |nitclkPythonVersion| image:: http://img.shields.io/pypi/pyversions/nitclk.svg
:alt: NI-TClk supported Python versions
:target: http://pypi.python.org/pypi/nitclk


.. |nitclkOpenIssues| image:: https://img.shields.io/github/issues/ni/nimi-python/nitclk.svg
:alt: Open Issues + Pull Requests for NI-TClk
:target: https://github.com/ni/nimi-python/issues?q=is%3Aopen+is%3Aissue+label%3Anitclk


.. |nitclkOpenPRs| image:: https://img.shields.io/github/issues-pr/ni/nimi-python/nitclk.svg
:alt: Pull Requests for NI-TClk
:target: https://github.com/ni/nimi-python/pulls?q=is%3Aopen+is%3Aissue+label%3Anitclk


.. _installation-section:

Installation
Expand Down
11 changes: 11 additions & 0 deletions docs/_static/nitclk_usage.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Usage
------

The following is a basic example of using the **nitclk** module

.. code-block:: python

import nitclk

Additional examples for NI-TClk are located in src/nitclk/examples/ directory.

960 changes: 960 additions & 0 deletions docs/nitclk/class.rst

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions docs/nitclk/errors.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
Exceptions and Warnings
=======================

DriverError
-----------

.. py:currentmodule:: nitclk
.. exception:: DriverError

An error originating from the NI-TClk driver


UnsupportedConfigurationError
-----------------------------

.. py:currentmodule:: nitclk
.. exception:: UnsupportedConfigurationError

An error due to using this module in an usupported platform.

DriverNotInstalledError
-----------------------

.. py:currentmodule:: nitclk
.. exception:: DriverNotInstalledError

An error due to using this module without the driver runtime installed.

InvalidRepeatedCapabilityError
------------------------------

.. py:currentmodule:: nitclk
.. exception:: InvalidRepeatedCapabilityError

An error due to an invalid character in a repeated capability


SelfTestError
-------------

.. py:currentmodule:: nitclk
.. exception:: SelfTestError

An error due to a failed self-test


DriverWarning
-------------

.. py:currentmodule:: nitclk
.. exception:: DriverWarning

A warning originating from the NI-TClk driver



18 changes: 18 additions & 0 deletions docs/nitclk/installation.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

.. _nitclk_installation-section:

Installation
------------

As a prerequisite to using the nitclk module, you must install the NI-TClk runtime on your system. Visit `ni.com/downloads <http://www.ni.com/downloads/>`_ to download the driver runtime for your devices.

The nimi-python modules (i.e. for **NI-TClk**) can be installed with `pip <http://pypi.python.org/pypi/pip>`_::

$ python -m pip install nitclk~=0.1.0.dev0

Or **easy_install** from
`setuptools <http://pypi.python.org/pypi/setuptools>`_::

$ python -m easy_install nitclk


41 changes: 41 additions & 0 deletions docs/nitclk/status.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

NI-TClk Python API Status
-------------------------

+-------------------------------+-----------------------+
| NI-TClk (nitclk) | |
+===============================+=======================+
| Driver Version Tested Against | 18.0.0 |
+-------------------------------+-----------------------+
| Driver API Version | 255.0.0d0 |
+-------------------------------+-----------------------+
| PyPI Version | |nitclkLatestVersion| |
+-------------------------------+-----------------------+
| Supported Python Version | |nitclkPythonVersion| |
+-------------------------------+-----------------------+
| Open Issues | |nitclkOpenIssues| |
+-------------------------------+-----------------------+
| Open Pull Requests | |nitclkOpenPRs| |
+-------------------------------+-----------------------+


.. |nitclkLatestVersion| image:: http://img.shields.io/pypi/v/nitclk.svg
:alt: Latest NI-TClk Version
:target: http://pypi.python.org/pypi/nitclk


.. |nitclkPythonVersion| image:: http://img.shields.io/pypi/pyversions/nitclk.svg
:alt: NI-TClk supported Python versions
:target: http://pypi.python.org/pypi/nitclk


.. |nitclkOpenIssues| image:: https://img.shields.io/github/issues/ni/nimi-python/nitclk.svg
:alt: Open Issues + Pull Requests for NI-TClk
:target: https://github.com/ni/nimi-python/issues?q=is%3Aopen+is%3Aissue+label%3Anitclk


.. |nitclkOpenPRs| image:: https://img.shields.io/github/issues-pr/ni/nimi-python/nitclk.svg
:alt: Pull Requests for NI-TClk
:target: https://github.com/ni/nimi-python/pulls?q=is%3Aopen+is%3Aissue+label%3Anitclk


10 changes: 10 additions & 0 deletions docs/nitclk/toc.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
API Reference
--------------

.. toctree::
:maxdepth: 6

nitclk/class
nitclk/errors
nitclk/examples

95 changes: 95 additions & 0 deletions generated/nitclk/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# -*- coding: utf-8 -*-
# This file was generated


__version__ = '0.1.0.dev0'

from nitclk.errors import DriverWarning # noqa: F401
from nitclk.errors import Error # noqa: F401
from nitclk.session import Session # noqa: F401


def get_diagnostic_information():
'''Get diagnostic information about the system state that is suitable for printing or logging
returns: dict
note: Python bitness may be incorrect when running in a virtual environment
'''
import os
import pkg_resources
import platform
import struct
import sys

def is_python_64bit():
return (struct.calcsize("P") == 8)

def is_os_64bit():
return platform.machine().endswith('64')

def is_venv():
return 'VIRTUAL_ENV' in os.environ

info = {}
info['os'] = {}
info['python'] = {}
info['driver'] = {}
info['module'] = {}
if platform.system() == 'Windows':
try:
import winreg as winreg
except ImportError:
import _winreg as winreg

os_name = 'Windows'
try:
driver_version_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\National Instruments\NI-TClk\CurrentVersion")
driver_version = winreg.QueryValueEx(driver_version_key, "Version")[0]
except WindowsError:
driver_version = 'Unknown'
elif platform.system() == 'Linux':
os_name = 'Linux'
driver_version = 'Unknown'
else:
raise SystemError('Unsupported platform: {}'.format(platform.system()))

installed_packages = pkg_resources.working_set
installed_packages_list = [{'name': i.key, 'version': i.version, } for i in installed_packages]

info['os']['name'] = os_name
info['os']['version'] = platform.version()
info['os']['bits'] = '64' if is_os_64bit() else '32'
info['driver']['name'] = "NI-TClk"
info['driver']['version'] = driver_version
info['module']['name'] = 'nitclk'
info['module']['version'] = "0.1.0.dev0"
info['python']['version'] = sys.version
info['python']['bits'] = '64' if is_python_64bit() else '32'
info['python']['is_venv'] = is_venv()
info['python']['packages'] = installed_packages_list

return info


def print_diagnostic_information():
'''Print diagnostic information in a format suitable for issue report
note: Python bitness may be incorrect when running in a virtual environment
'''
info = get_diagnostic_information()

row_format = ' {:<10} {}'
for type in ['OS', 'Driver', 'Module', 'Python']:
typename = type.lower()
print(type + ':')
for item in info[typename]:
if item != 'packages':
print(row_format.format(item.title() + ':', info[typename][item]))
print(' Installed Packages:')
for p in info['python']['packages']:
print((' ' * 8) + p['name'] + '==' + p['version'])

return info


0 comments on commit 5de4716

Please sign in to comment.