Skip to content

Commit

Permalink
Merge pull request #35 from Semi-ATE/29-issue
Browse files Browse the repository at this point in the history
29 issue
  • Loading branch information
seimit authored Aug 21, 2022
2 parents c9d3afd + 5a80ad3 commit c2e123a
Show file tree
Hide file tree
Showing 30 changed files with 1,344 additions and 65 deletions.
61 changes: 32 additions & 29 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,35 @@ jobs:
make-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.8'
- name: Install dependencies
run: |
pip install -r requirements/run.txt
pip install -r requirements/test.txt
- name: tag to version
run: echo -e "# Copyright (c) Semi-ATE\n# Distributed under the terms of the GPLv2 License\n__version__='${GITHUB_REF#refs/*/}'" > Metis/__init__.py
- name: Run tests
run: pytest --cov=Metis
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
- name: Create package
run: python setup.py sdist
- name: Check package
run: twine check dist/*
- name: Check manifest
run: check-manifest
- name: Upload to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: python -m twine upload dist/*
- name: Checkout
uses: actions/checkout@v2
- name: Install mamba & environment
uses: mamba-org/provision-with-micromamba@v11
- name: Setup dependencies
shell: bash -l {0}
run: |
sudo apt-get install -y libhdf5-dev inotify-tools libgirepository1.0-dev gstreamer-1.0 gstreamer1.0-tools gstreamer1.0-python3-plugin-loader gir1.2-gstreamer-1.0 gstreamer1.0-clutter-3.0 gstreamer1.0-crystalhd gstreamer1.0-gl gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-pulseaudio gstreamer1.0-x libclutter-gst-3.0-0 libgstreamer-gl1.0-0 libgstreamer-plugins-base1.0-0 libgstreamer-plugins-good1.0-0 libgstreamer1.0-0 libgstreamer1.0-dev inotify-tools libinotifytools0
pip install tables gobject inotify
# registering metis plugins
gst-inspect-1.0
# GST_DEBUG=6 gst-inspect-1.0 > gst_plugins_list
# cat gst_plugins_list

- name: Run tests
shell: bash -l {0}
run: |
pytest -s
- name: Create debian package
run: |
cd Metis
make package
cp ../*.deb ../dist/
- name: Rename assets
run:
mv ./dist/*.tar.gz ./dist/metis-server_${GITHUB_REF##*/}_linux_amd64.tar.gz
- name: Upload Release Assets
uses: alexellis/upload-assets@0.3.0
env:
GITHUB_TOKEN: ${{ github.token }}
with:
asset_paths: '["./dist/*"]'
50 changes: 16 additions & 34 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,28 @@ name: CI

on: [push]

env:
GST_PLUGIN_PATH: /home/runner/work/Metis/Metis/Metis

jobs:
test-linux:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install mamba & environment
uses: mamba-org/provision-with-micromamba@v11
- name: Setup dependencies
shell: bash -l {0}
run: |
pip install -r requirements/run.txt
pip install -r requirements/test.txt
sudo apt-get install -y libhdf5-dev inotify-tools libgirepository1.0-dev gstreamer-1.0 gstreamer1.0-tools gstreamer1.0-python3-plugin-loader gir1.2-gstreamer-1.0 gstreamer1.0-clutter-3.0 gstreamer1.0-crystalhd gstreamer1.0-gl gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-pulseaudio gstreamer1.0-x libclutter-gst-3.0-0 libgstreamer-gl1.0-0 libgstreamer-plugins-base1.0-0 libgstreamer-plugins-good1.0-0 libgstreamer1.0-0 libgstreamer1.0-dev inotify-tools libinotifytools0
pip install tables gobject inotify
# registering metis plugins
gst-inspect-1.0
# GST_DEBUG=6 gst-inspect-1.0 > gst_plugins_list
# cat gst_plugins_list

- name: Run tests
run: pytest tests/ --cov=Metis
- name: Create package
run: python setup.py sdist
- name: Check package
run: twine check dist/*
- name: Check manifest
run: check-manifest
# test-windows:
# runs-on: windows-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# - name: Setup python
# uses: actions/setup-python@v2
# with:
# python-version: '3.8'
# - name: Setup dependencies
# run: |
# pip install -r requirements/run.txt
# pip install -r requirements/test.txt
# - name: Run tests
# run: pytest tests/ --cov=Semi_ATE
# - name: Create package
# run: python setup.py sdist
# - name: Check package
# run: twine check dist/*
# - name: Check manifest
# run: check-manifest
shell: bash -l {0}
run: |
pytest -s
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ __pycache__/
# C extensions
*.so

*~

# Distribution / packaging
.Python
build/
Expand Down
28 changes: 28 additions & 0 deletions Metis/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

all:

package:
cp debian/changelog debian/changelog.org
cp debian/control debian/control.org
@sed s/'__DATE_TIME__'/'$(shell date +"%a, %d %b %Y %T %z")'/ debian/changelog > debian/changelog.temp
@sed s/'__VERSION__'/"$(shell cat ver)"/ debian/changelog.temp > debian/changelog
@sed s/'__ARCH__'/"$(shell cat arch)"/ debian/control > debian/control.temp
cp debian/control.temp debian/control
debuild -i -us -uc -b
mv debian/changelog.org debian/changelog
mv debian/control.org debian/control

clean:
rm -f *.so
rm -f *.o
rm -f *~
rm -f stil_loader
rm -rf debian/metis-server
rm -rf debian/metis-server.debhelper.log
rm -rf debian/metis-server.substvars
rm -rf debian/.debhelper
rm -rf debian/changelog.temp
rm -rf debian/control.temp
rm -rf debian/files
rm -rf debian/*~

1 change: 1 addition & 0 deletions Metis/arch
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
amd64
5 changes: 5 additions & 0 deletions Metis/debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
metis-server (__VERSION__) stable; urgency=low

* See changelog file in the github release page.

-- Velislav-Boyanov <vboy@semi-ate.com> __DATE_TIME__
1 change: 1 addition & 0 deletions Metis/debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9
12 changes: 12 additions & 0 deletions Metis/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Source: metis-server
Section: unknown
Priority: optional
Maintainer: Velislav-Boyanov <vboy@semi-ate.com>
Standards-Version: 4.0.0
Homepage: https://github.com/Semi-ATE/Metis

Package: metis-server
Architecture: amd64
Depends: libhdf5-dev, inotify-tools
Description: Metis server.
Server for converting STDF files into hdf5 files.
2 changes: 2 additions & 0 deletions Metis/debian/files
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
metis-server_0.0.1_amd64.buildinfo unknown optional
metis-server_0.0.1_amd64.deb unknown optional
29 changes: 29 additions & 0 deletions Metis/debian/metis-server.postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh
# postinst script for cpython
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
configure)
touch /var/log/metisd.log
chmod 777 /var/log/metisd.log
chmod +x /usr/share/metis/start_metis.sh
;;
esac

exit 0
29 changes: 29 additions & 0 deletions Metis/debian/metis-server.prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh
# postinst script for cpython
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
upgrade)
rm -rf /usr/share/metis/python/__pycache__
systemctl stop metis
systemctl disable metis
;;
esac

exit 0
20 changes: 20 additions & 0 deletions Metis/debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/make -f
#DH_VERBOSE = 1

clean:
make clean

build:
make all

binary:
mkdir -p debian/metis-server/etc/systemd/system
mkdir -p debian/metis-server/usr/share/metis/python
cp metisd.yaml debian/metis-server/etc
cp sinotify.py debian/metis-server/usr/share/metis
cp systemd/start_metis.sh debian/metis-server/usr/share/metis
cp systemd/metis.service debian/metis-server/etc/systemd/system
cp -a python/. debian/metis-server/usr/share/metis/python
dh_gencontrol
dh_installdeb
dh_builddeb
12 changes: 12 additions & 0 deletions Metis/metisd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
metis:
paths:
main-daemon-path: "/mnt/stdf"
write-path: "/tmp/"
pid-path: "/tmp/metisd.pid"
log:
logging: 1 # 0=>logging off, 1=>logging on
log-path: "/var/log/metisd.log"
log-level: "INFO" # "INFO" "WARNING" "ERROR" "DEBUG" "CRITICAL" "NOTSET"

38 changes: 38 additions & 0 deletions Metis/python/MetisConfig.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import os
import sys
import logging
from yaml import safe_load

file_loc = os.path.dirname(__file__)
test_loc = os.path.join(file_loc, "../../tests/test_metisd.yaml")

class MetisConfig():

def __init__(self):

self.config = self.load_config()

if self.config['metis']['log']['logging'] == True:
loglevel = self.config['metis']['log']['log-level']
numeric_level = getattr(logging, loglevel.upper(), None)
log_path = self.config['metis']['log']['log-path']
logging.basicConfig(filename=log_path, filemode='a', level=numeric_level)

def load_config(self):
"""Loads yaml file"""
try:
# In the case of normal deamon mode:
with open("/etc/metisd.yaml", "r") as f:
config_data = safe_load(f)
return config_data
except:
# In the case of test mode:
try:
with open(test_loc, "r") as f:
config_data = safe_load(f)
return config_data
except Exception as e:
error = f'Could not open config file, {e}.'
sys.exit(error)
os._exit

69 changes: 69 additions & 0 deletions Metis/python/metis_process.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
"""
Created on Wed Jan 26 17:22:18 2022
@author: nz
"""


import gi

gi.require_version("Gst", "1.0")
gi.require_version('GstBase', '1.0')

from gi.repository import Gst, GObject, GstBase
Gst.init(None)


class metis_process(GstBase.BaseTransform):
__gstmetadata__ = ("Process plugin",
"Transform",
"Process stdf content if required",
"vboy")

__gsttemplates__ = (Gst.PadTemplate.new("src",
Gst.PadDirection.SRC,
Gst.PadPresence.ALWAYS,
Gst.Caps.new_any()),
Gst.PadTemplate.new("sink",
Gst.PadDirection.SINK,
Gst.PadPresence.ALWAYS,
Gst.Caps.new_any()))


def __init__(self):
GstBase.BaseTransform.__init__(self)
# self.max_needed_buffer_size = 65536
#super().set_blocksize(self.max_needed_buffer_size)

def do_set_property(self, prop, value):
if prop.name == 'in_file':
self.in_file = value

def do_start(self):
print("Metis process plugin started")
return True

#Passthrough mode
#Element has no interest in modifying the buffer.
#It may want to inspect it, in which case the element should have a transform_ip function.
#If there is no transform_ip function in passthrough mode, the buffer is pushed intact.
def do_transform_ip(self, buf):
pass
#def do_transform(self, inbuf, outbuf):
# print("Sending.")
#try:
#buf.memset(0, 0, self.max_needed_buffer_size)
#with buf.map(Gst.MapFlags.READ) as info:
# buffer = info.data.copy()
# print("dasd")

#except Exception as e:
# Gst.error("Mapping error: %s" % e)
# return Gst.FlowReturn.ERROR

return (Gst.FlowReturn.OK, buf)


# Register plugin to use it from command line
GObject.type_register(metis_process)
__gstelementfactory__ = ("metis_process", Gst.Rank.NONE, metis_process)
Loading

0 comments on commit c2e123a

Please sign in to comment.