diff --git a/.gitignore b/.gitignore index f523f52..ff722b0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ build *~ ognibuild.egg-info dist +__pycache__ diff --git a/ognibuild/session/__init__.py b/ognibuild/session/__init__.py new file mode 100644 index 0000000..6917def --- /dev/null +++ b/ognibuild/session/__init__.py @@ -0,0 +1,66 @@ +#!/usr/bin/python +# Copyright (C) 2020 Jelmer Vernooij +# encoding: utf-8 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +from typing import Optional, List, Dict + + +class Session(object): + + def __enter__(self) -> 'Session': + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + return False + + def chdir(self, cwd: str) -> None: + raise NotImplementedError(self.chdir) + + @property + def location(self) -> str: + raise NotImplementedError(self.location) + + def check_call( + self, + argv: List[str], cwd: Optional[str] = None, + user: Optional[str] = None, + env: Optional[Dict[str, str]] = None): + raise NotImplementedError(self.check_call) + + def check_output( + self, + argv: List[str], cwd: Optional[str] = None, + user: Optional[str] = None, + env: Optional[Dict[str, str]] = None) -> bytes: + raise NotImplementedError(self.check_output) + + def Popen(self, argv, cwd: Optional[str] = None, + user: Optional[str] = None, **kwargs): + raise NotImplementedError(self.Popen) + + def call( + self, argv: List[str], cwd: Optional[str] = None, + user: Optional[str] = None): + raise NotImplementedError(self.call) + + def create_home(self) -> None: + """Create the user's home directory.""" + raise NotImplementedError(self.create_home) + + +class SessionSetupFailure(Exception): + """Session failed to be set up."""