Created
March 13, 2016 22:31
-
-
Save mcomisso/41c4b85334c19022da2f to your computer and use it in GitHub Desktop.
Example of classes with dynamically selectors in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Http_Server(object): | |
environment = {} | |
def __init__(self, env): | |
self.environment = env | |
print self.environment | |
# Dynamically fetch the environments variables for the operating system | |
self.os = getattr(__import__('enheritage'), self.environment.get('os', 'Debian')) | |
def reload(self): | |
raise NotImplementedError | |
def restart(self): | |
raise NotImplementedError | |
def graceful(self): | |
raise NotImplementedError | |
def create_directories(self): | |
raise NotImplementedError | |
class Apache(Http_Server): | |
def restart(self): | |
pass | |
def reload(self): | |
pass | |
def graceful(self): | |
pass | |
class Nginx(Http_Server): | |
def restart(self): | |
pass | |
def reload(self): | |
pass | |
def graceful(self): | |
pass | |
class Environments(object): | |
def __init__(self, configuration): | |
self.executablePath = configuration.get('exec', '') | |
class Debian(Environments): | |
current_name='ubuntu_12.04' | |
pass | |
class RedHat(Environments): | |
current_name='RH_1010' | |
pass | |
if __name__ == '__main__': | |
environ = {'test': 'test', 'os': 'Debian'} | |
apache = Apache(environ) | |
print apache.os.current_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment