# Path: subuserlib/test.py
# def getUser():
# 
# Path: subuserlib/paths.py
# def upNDirsInPath(path,n):
# def getSubuserDir():
# def getSubuserExecutable():
# def getSubuserDataFile(filename):
# 
# Path: subuserlib/classes/userOwnedObject.py
# class UserOwnedObject(object):
#   def __init__(self,user):
#     self.user = user


import getpass
import os
import sys
import pwd
import subprocess
    import functools,time
from subuserlib import test
from subuserlib import paths
from subuserlib.classes.userOwnedObject import UserOwnedObject

  #@timeit
  def callCollectOutput(self,args,cwd=None,decode='utf-8'):
    """
    Run the command and return a tuple with: (returncode,the output to stdout as a string,stderr as a string).
    """
    args = self.getSudoArgs() + args
    process = subprocess.Popen(args,stdout=subprocess.PIPE,stderr=subprocess.PIPE,cwd=cwd)
    (stdout,stderr) = process.communicate()
    if decode:
        return (process.returncode,stdout.decode("utf-8"),stderr.decode("utf-8"))
    else:
        return (process.returncode,stdout,stderr)


  def Popen(self,command,*args,**kwargs):
    return subprocess.Popen(self.getSudoArgs()+command,*args,**kwargs)

  def runEditor(self,filePath):
    """
    Launch a file editor and edit the given filePath.
    """
    try:
      editor = os.environ["EDITOR"]
    except KeyError:
      editor = "/usr/bin/nano"
    def actuallyRunEditor(editor,filePath):
      try:
        self.call([editor,filePath])
      except FileNotFoundError:

# Path: subuserlib/test.py
# def getUser():
# 
# Path: subuserlib/paths.py
# def upNDirsInPath(path,n):
# def getSubuserDir():
# def getSubuserExecutable():
# def getSubuserDataFile(filename):
# 
# Path: subuserlib/classes/userOwnedObject.py
# class UserOwnedObject(object):
#   def __init__(self,user):
#     self.user = user


# Path: subuserlib/classes/endUser.py
import getpass
import os
import sys
import pwd
import subprocess
    import functools,time
from subuserlib import test
from subuserlib import paths
from subuserlib.classes.userOwnedObject import UserOwnedObject


  #@timeit
  def callCollectOutput(self,args,cwd=None,decode='utf-8'):
    """
    Run the command and return a tuple with: (returncode,the output to stdout as a string,stderr as a string).
    """
    args = self.getSudoArgs() + args
    process = subprocess.Popen(args,stdout=subprocess.PIPE,stderr=subprocess.PIPE,cwd=cwd)
    (stdout,stderr) = process.communicate()
    if decode:
        return (process.returncode,stdout.decode("utf-8"),stderr.decode("utf-8"))
    else:
        return (process.returncode,stdout,stderr)


  def Popen(self,command,*args,**kwargs):
    return subprocess.Popen(self.getSudoArgs()+command,*args,**kwargs)

  def runEditor(self,filePath):
    """
    Launch a file editor and edit the given filePath.
    """
    try:
      editor = os.environ["EDITOR"]
    except KeyError:
      editor = "/usr/bin/nano"
    def actuallyRunEditor(editor,filePath):
      try:
        self.call([editor,filePath])
      except FileNotFoundError:

        if test.testing: