Skip to content

Commit

Permalink
fix: Support new way AnyBody 8.0.3 stores it's registry keys (#112)
Browse files Browse the repository at this point in the history
* fix: Support the new way AnyBody 8.0.1 stores the registry keys

* Run ruff/isort

* Update version

* Update docs build environment

* update lock file

* Add pytest to docs build environmenton

* fix typo

* Add anyboydcon as dependency when testing on windows
  • Loading branch information
melund authored May 23, 2024
1 parent c865273 commit 2badedc
Show file tree
Hide file tree
Showing 6 changed files with 6,738 additions and 1,523 deletions.
106 changes: 75 additions & 31 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,92 @@ concurrency:
cancel-in-progress: true

jobs:
sphinx-build:
build-latest-docs:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install mamba
uses: mamba-org/setup-micromamba@main
- uses: prefix-dev/[email protected]
with:
environment-file: docs/environment.yml

- name: Build anypytools
shell: bash -l {0}
run: pip install .
environments: docs
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'master' }}
activate-environment: docs

- name: Build Documentation
shell: bash -l {0}
run: |
set -e
cd docs
make html-dev
sphinx-build -M html . _build -W --keep-going -a -t DEV_BUILD
cd ..
mkdir -p public/dev
cp -rT docs/_build/html public/dev
- name: Build last tagged version
if: github.ref == 'refs/heads/master'
shell: bash -l {0}
- uses: actions/upload-artifact@v4
with:
name: dev-version
path: docs/_build/html



build-tagged-docs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

# - name: Checkout last tagged version
# run: |
# git checkout $(git describe --tags `git rev-list --tags --max-count=1`);

- uses: prefix-dev/[email protected]
with:
environments: docs
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'master' }}
activate-environment: docs

- name: Build Documentation
run: |
git checkout $(git describe --tags `git rev-list --tags --max-count=1`);
cd docs
make clean
make html
cd ..
cp -rT docs/_build/html public
- name: Deploy 🚀
if: github.ref == 'refs/heads/master'
uses: peaceiris/actions-gh-pages@v3
sphinx-build -M html . _build -a
- uses: actions/upload-artifact@v4
with:
name: tagged-version
path: docs/_build/html


prepare-pages:
needs: [build-latest-docs, build-tagged-docs]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
external_repository: AnyBody-Research-Group/anypytools-docs
publish_branch: gh-pages
publish_dir: ./public
name: tagged-version
path: public
- uses: actions/download-artifact@v4
with:
name: dev-version
path: public/dev
- uses: actions/upload-pages-artifact@v3
with:
path: public

deploy:
needs: prepare-pages
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4


26 changes: 11 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,14 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: prefix-dev/setup-pixi@v0.5.1
- uses: prefix-dev/setup-pixi@v0.7.0
with:
post-cleanup: true
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}

- name: build
run: pixi run --frozen pip install .

environments: test
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'master' }}
activate-environment: test

- name: Test with pytest
run: pixi run --frozen pytest tests
run: pytest tests
env:
RLM_LICENSE_PASSWORD: ${{ secrets.LICENSE_PASSWORD }}
RLM_LICENSE: ${{ secrets.LICENSE_SERVER }}
Expand All @@ -51,16 +49,14 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: prefix-dev/setup-pixi@v0.5.1
- uses: prefix-dev/setup-pixi@v0.7.0
with:
post-cleanup: true
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}

- name: build
run: pixi run --frozen pip install .
environments: test
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'master' }}
activate-environment: test

- name: test
env:
RLM_LICENSE_PASSWORD: ${{ secrets.LICENSE_PASSWORD }}
RLM_LICENSE: ${{ secrets.LICENSE_SERVER }}
run: pixi run --frozen pytest tests
run: pytest tests
9 changes: 4 additions & 5 deletions anypytools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
# -*- coding: utf-8 -*-
"""AnyPyTools library."""
import logging
import os
import sys
import platform
import logging
import sys

if "FOR_DISABLE_CONSOLE_CTRL_HANDLER" not in os.environ:
os.environ["FOR_DISABLE_CONSOLE_CTRL_HANDLER"] = "1"

from anypytools import macro_commands
from anypytools.abcutils import AnyPyProcess, execute_anybodycon
from anypytools.macroutils import AnyMacro
from anypytools import macro_commands
from anypytools.tools import (
ABOVE_NORMAL_PRIORITY_CLASS,
BELOW_NORMAL_PRIORITY_CLASS,
IDLE_PRIORITY_CLASS,
NORMAL_PRIORITY_CLASS,
)


logger = logging.getLogger("abt.anypytools")
logger.addHandler(logging.NullHandler())

Expand All @@ -37,7 +36,7 @@
"NORMAL_PRIORITY_CLASS",
]

__version__ = "1.11.5"
__version__ = "1.11.6"


def print_versions():
Expand Down
37 changes: 21 additions & 16 deletions anypytools/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,27 @@
"""
from __future__ import annotations

import os
import re
import sys
import xml
import collections
import copy
import datetime
import errno
import shutil
import functools
import logging
import textwrap
import datetime
import warnings
import os
import platform
import functools
import subprocess
import collections
import pprint
import re
import shutil
import subprocess
import sys
import textwrap
import warnings
import xml
from _thread import get_ident as _get_ident
from ast import literal_eval
from pathlib import Path
from contextlib import suppress
from dataclasses import dataclass
from _thread import get_ident as _get_ident

from pathlib import Path
from typing import Any, Iterable

# external imports
Expand Down Expand Up @@ -527,10 +526,16 @@ def _expand_short_path_name(short_path_name):
def lookup_anybody_in_registry() -> str | None:
import winreg

try:
anybodykey = winreg.QueryValue(winreg.HKEY_CLASSES_ROOT, ".any")
except OSError:
anybodykey = "AnyBody.any"

keys_to_try = [
"AnyBody.any\\shell\\open\\command",
f"{anybodykey}\\shell\\open\\command",
"AnyBody.AnyScript\\shell\\open\\command",
]

for key in keys_to_try:
try:
value = winreg.QueryValue(winreg.HKEY_CLASSES_ROOT, key)
Expand Down Expand Up @@ -716,7 +721,7 @@ def _get_index_length(self, index_var="auto"):
timevars = [var for var in self if var.endswith("Output.Abscissa.t")]
if len(timevars) > 1:
raise ValueError(
f"Multiple time variables found. Use 'index_var' argument to indicate which to use."
"Multiple time variables found. Use 'index_var' argument to indicate which to use."
)
if len(timevars) == 0:
raise ValueError(
Expand Down
Loading

0 comments on commit 2badedc

Please sign in to comment.