Skip to content

Commit

Permalink
removing duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
tfoote committed Feb 8, 2019
1 parent ac3afc5 commit 92f9ded
Showing 1 changed file with 0 additions and 85 deletions.
85 changes: 0 additions & 85 deletions src/rocker/nvidia_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,88 +107,3 @@ def register_arguments(parser):
help="Enable nvidia")


class PulseAudio(RockerExtension):
@staticmethod
def get_name():
return 'pulse'

def __init__(self):
self._env_subs = None
self.name = PulseAudio.get_name()


def get_environment_subs(self):
if not self._env_subs:
self._env_subs = {}
self._env_subs['user_id'] = os.getuid()
self._env_subs['XDG_RUNTIME_DIR'] = os.getenv('XDG_RUNTIME_DIR')
self._env_subs['audio_group_id'] = grp.getgrnam('audio').gr_gid
return self._env_subs

def get_preamble(self, cliargs):
return ''

def get_snippet(self, cliargs):
snippet = pkgutil.get_data('rocker', 'templates/%s_snippet.Dockerfile.em' % self.name).decode('utf-8')
return em.expand(snippet, self.get_environment_subs())

def get_docker_args(self, cliargs):
args = ' -v /run/user/%(user_id)s/pulse:/run/user/%(user_id)s/pulse --device /dev/snd '\
' -e PULSE_SERVER=unix:%(XDG_RUNTIME_DIR)s/pulse/native -v %(XDG_RUNTIME_DIR)s/pulse/native:%(XDG_RUNTIME_DIR)s/pulse/native --group-add %(audio_group_id)s '
return args % self.get_environment_subs()

def precondition_environment(self, cliargs):
pass

@staticmethod
def register_arguments(parser):
parser.add_argument(name_to_argument(PulseAudio.get_name()),
action='store_true',
help="mount pulse audio devices")


class HomeDir(RockerExtension):
@staticmethod
def get_name():
return 'home'

def __init__(self):
self.name = HomeDir.get_name()

def get_docker_args(self, cliargs):
return ' -v %s:%s ' % (Path.home(), Path.home())

@staticmethod
def register_arguments(parser):
parser.add_argument(name_to_argument(HomeDir.get_name()),
action='store_true',
help="mount the users home directory")


class User(RockerExtension):
@staticmethod
def get_name():
return 'user'

def get_environment_subs(self):
if not self._env_subs:
self._env_subs = {}
self._env_subs['user_id'] = os.getuid()
self._env_subs['username'] = getpass.getuser()
return self._env_subs

def __init__(self):
self._env_subs = None
self.name = User.get_name()

def get_snippet(self, cliargs):
snippet = pkgutil.get_data('rocker', 'templates/%s_snippet.Dockerfile.em' % self.name).decode('utf-8')
return em.expand(snippet, self.get_environment_subs())

@staticmethod
def register_arguments(parser):
parser.add_argument(name_to_argument(User.get_name()),
action='store_true',
help="mount the users home directory")


0 comments on commit 92f9ded

Please sign in to comment.