Skip to content

Commit

Permalink
Merge branch 'main' of github.com:cloudmesh/cloudmesh-common
Browse files Browse the repository at this point in the history
  • Loading branch information
laszewsk committed Dec 13, 2023
2 parents 1af62b7 + 8490165 commit 9f01a62
Show file tree
Hide file tree
Showing 34 changed files with 331 additions and 180 deletions.
12 changes: 0 additions & 12 deletions .bumpversion.cfg

This file was deleted.

99 changes: 99 additions & 0 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Python Package using Conda

on: [push]

jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
max-parallel: 5

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- name: Add extra channels
run: |
conda config --add channels conda-forge
conda config --add channels defaults
- name: Install dependencies
run: |
conda env update --file environment.yml --name base
- name: Lint with flake8
run: |
conda install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 --exclude deprecated . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 --exclude deprecated . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Install current Python library
run: |
source activate base # Activate the conda environment
pip install -e . # Install the current Python library in editable mode
pip install cloudmesh-vpn
- name: Test with pytest
run: |
conda install pytest
source activate base & pytest tests -rsx
build-windows:
runs-on: windows-latest
strategy:
max-parallel: 5

steps:
# - uses: actions/checkout@v3
# - name: Set up Python 3.10
# uses: conda-incubator/setup-miniconda@v2
# with:
# miniconda-version: "latest"
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: '3.10'
# - name: Add conda to system path
# run: |
# # $CONDA is an environment variable pointing to the root of the miniconda directory
# echo $CONDA/bin >> $GITHUB_PATH
# - name: Add extra channels
# run: |
# conda config --add channels conda-forge
# conda config --add channels defaults

# - name: Install dependencies
# run: |
# conda env update --file environment.yml --name base
- name: set up env3
run: |
python -m venv ENV3
- name: Lint with flake8
run: |
.\ENV3\Scripts\activate.ps1
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 --exclude deprecated . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 --exclude deprecated . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Install current Python library
run: |
.\ENV3\Scripts\activate.ps1
pip install -e . # Install the current Python library in editable mode
pip install cloudmesh-vpn
- name: Test with pytest
run: |
.\ENV3\Scripts\activate.ps1
pip install pytest
pytest tests -rsx
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ include VERSION
include *.md
include LICENSE
include requirements-dev.txt
graft cloudmesh/common/bin
38 changes: 8 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ clean:
# PYPI
######################################################################


twine:
pip install -U twine

Expand All @@ -67,19 +66,21 @@ dist:

patch: clean twine
$(call banner, "patch")
bump2version --allow-dirty patch
cms bumpversion patch
python setup.py sdist bdist_wheel
git push origin main --tags
twine check dist/*
twine upload --repository testpypi dist/*
# $(call banner, "install")
# pip search "cloudmesh" | fgrep cloudmesh-$(package)
# sleep 10
# pip install --index-url https://test.pypi.org/simple/ cloudmesh-$(package) -U

minor: clean
$(call banner, "minor")
bump2version minor --allow-dirty
cms bumpversion minor
@cat VERSION
@echo

major: clean
$(call banner, "major")
cms bumpversion major
@cat VERSION
@echo

Expand All @@ -93,18 +94,6 @@ release: clean
$(call banner, "install")
@cat VERSION
@echo
# sleep 10
# pip install -U cloudmesh-common


dev:
bump2version --new-version "$(VERSION)-dev0" part --allow-dirty
bump2version patch --allow-dirty
@cat VERSION
@echo

reset:
bump2version --new-version "4.0.0-dev0" part --allow-dirty

upload:
twine check dist/*
Expand All @@ -113,19 +102,8 @@ upload:
pip:
pip install --index-url https://test.pypi.org/simple/ cloudmesh-$(package) -U

# --extra-index-url https://test.pypi.org/simple

log:
$(call banner, log)
gitchangelog | fgrep -v ":dev:" | fgrep -v ":new:" > ChangeLog
git commit -m "chg: dev: Update ChangeLog" ChangeLog
git push

# bump:
# git checkout main
# git pull
# tox
# python setup.py sdist bdist_wheel upload
# bumpversion --no-tag patch
# git push origin main --tags

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.3.195
5.0.3
23 changes: 23 additions & 0 deletions bin/set-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python

import argparse
import subprocess

# usage python set-version.py --version 4.4.0

def set_version(new_version):
try:
# Call bump2version with --allow-dirty --new-version X.X.X patch
subprocess.run(['bump2version', '--allow-dirty', f'--new-version="{new_version}"', 'part'], check=True)
print(f"Version set to {new_version} successfully.")
except subprocess.CalledProcessError as e:
print(f"Error: {e}")

if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Set version using bump2version.")
parser.add_argument('--version', help='New version in X.X.X format', required=True)

args = parser.parse_args()

new_version = args.version
set_version(new_version)
4 changes: 4 additions & 0 deletions bumpversion.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bumpversion:
- cloudmesh/bumpversion/__init__.py
- cloudmesh/bumpversion/__version__.py
- VERSION
19 changes: 0 additions & 19 deletions cloudmesh/__init__.py

This file was deleted.

7 changes: 5 additions & 2 deletions cloudmesh/common/FlatDict.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,11 @@ def values(self):
"""
return list(self.__dict__.values())

def __cmp__(self, dictionary):
return cmp(self.__dict__, dictionary)
# def __cmp__(self, dictionary):
# """
# deprecated
# """
# return cmp(self.__dict__, dictionary)

def __contains__(self, item):
return item in self.__dict__
Expand Down
15 changes: 12 additions & 3 deletions cloudmesh/common/Host.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from cloudmesh.common.parameter import Parameter
from cloudmesh.common.util import path_expand
from cloudmesh.common.util import readfile
from cloudmesh.common.systeminfo import os_is_windows
from pprint import pprint
from cloudmesh.common.Printer import Printer

Expand Down Expand Up @@ -233,6 +234,7 @@ def ssh(hosts=None,
ssh_command = ['ssh',
'-o', 'StrictHostKeyChecking=no',
'-o', 'UserKnownHostsFile=/dev/null',
'-o', 'PreferredAuthentications=publickey',
'-i', key,
'{host}',
f'{command}']
Expand Down Expand Up @@ -325,10 +327,17 @@ def _ping(args):
"""
ip = args['ip']
count = str(args['count'])
count_flag = '-n' if platform == 'windows' else '-c'
command = ['ping', count_flag, count, ip]

count_flag = '-n' if os_is_windows() else '-c'
if os_is_windows():
# adding ipv4 enforce for windows
# for some reason -4 is required or hosts
# fail. we need ipv4
command = ['ping', '-4', ip, count_flag, count]
else:
command = ['ping', count_flag, count, ip]
# command = ['ping', '-4', ip, count_flag, count]
result = subprocess.run(command, capture_output=True)

try:
timers = result.stdout \
.decode("utf-8", "ignore") \
Expand Down
Loading

0 comments on commit 9f01a62

Please sign in to comment.