deb-mock/mock/py/mockbuild/state.py
robojerk 4c0dcb2522
Some checks failed
Build Deb-Mock Package / build (push) Successful in 54s
Lint Code / Lint All Code (push) Failing after 1s
Test Deb-Mock Build / test (push) Failing after 36s
enhance: Add comprehensive .gitignore for deb-mock project
- Add mock-specific build artifacts (chroot/, mock-*, mockroot/)
- Include package build files (*.deb, *.changes, *.buildinfo)
- Add development tools (.coverage, .pytest_cache, .tox)
- Include system files (.DS_Store, Thumbs.db, ._*)
- Add temporary and backup files (*.tmp, *.bak, *.backup)
- Include local configuration overrides (config.local.yaml, .env.local)
- Add test artifacts and documentation builds
- Comprehensive coverage for Python build system project

This ensures build artifacts, chroot environments, and development
tools are properly ignored in version control.
2025-08-18 23:37:49 -07:00

43 lines
1.4 KiB
Python

# -*- coding: utf-8 -*-
# vim: noai:ts=4:sw=4:expandtab
from .exception import StateError
from .trace_decorator import getLog
class State(object):
def __init__(self, bootstrap=None):
self._state = []
# can be "unknown", "success" or "fail"
self.result = "unknown"
self.bootstrap = bootstrap
self.state_log = getLog("mockbuild.Root.state")
def state(self):
if not len(self._state):
raise StateError("state called on empty state stack")
return self._state[-1]
def start(self, state):
if state is None:
raise StateError("start called with None State")
self._state.append(state)
if self.bootstrap:
self.state_log.info("Start(bootstrap): %s", state)
else:
self.state_log.info("Start: %s", state)
def finish(self, state):
if len(self._state) == 0:
raise StateError("finish called on empty state list")
current = self._state.pop()
if state != current:
raise StateError("state finish mismatch: current: %s, state: %s" % (current, state))
if self.bootstrap:
self.state_log.info("Finish(bootstrap): %s", state)
else:
self.state_log.info("Finish: %s", state)
def alldone(self):
if len(self._state) != 0:
raise StateError("alldone called with pending states: %s" % ",".join(self._state))