Source code for pycif.utils.classes.platforms

from types import MethodType
import os
import subprocess
from .baseclass import Plugin


[docs]class Platform(Plugin): def __init__(self, **kwargs): """Create a Model Class""" super(Platform, self).__init__(**kwargs) # Default attributes self.sleep_time = 5 self.max_active_jobs = 40 self.env_variables = {}
[docs] def initiate_template(self): super(Platform, self).initiate_template( plg_type="platform", default_functions={"submit_job": True, "check_jobs": True} )
[docs] @classmethod def register_plugin(cls, name, version, module, subtype="", **kwargs): """Register a module for a plugin and version with possibly options Args: name (str): name of the plugin version (str): version of the plugin module (types.ModuleType): module defining the interface between pyCIF and the plugin plugin_type (str): type of plugin **kwargs (dictionary): default options for module """ super(Platform, cls).register_plugin( name, version, module, plugin_type="platform", subtype=subtype )
def submit_job(self, exe, job_file): process = subprocess.Popen( exe.split(), cwd=os.path.dirname(job_file), stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) stdout, stderr = process.communicate() def check_jobs(self, list_jobs): return True