예제 #1
0
파일: test_find.py 프로젝트: otmsol/dodai
def test_find_home_directory():
    """Basic test to make sure the home directory is returned.  Also checks
    to see if the passed in project_name is appended to the path in the
    returned value.
    """
    dir = find.home_direcotry()
    nt.ok_(os.path.exists(dir))

    project_name = 'test'
    dir = find.home_direcotry(project_name)
    project_name = ".{0}".format(project_name)
    nt.ok_(dir.endswith(project_name))
예제 #2
0
파일: base.py 프로젝트: otmsol/dodai
 def project_config_directory(self):
     """Property holding the project's config directory path in the
     home directory
     """
     if not self._project_config_directory_:
         self._project_config_directory_ = find.home_direcotry(
                         project_name=self.project_name)
     return self._project_config_directory_
예제 #3
0
파일: base.py 프로젝트: otmsol/dodai
 def _mkdir(self, project_name):
     """Creates the project config directory in the home directory.
     Also creates a empty file which is used to identify this as a test
     directory.
     """
     path = find.home_direcotry(project_name=project_name)
     os.mkdir(path)
     filename = os.path.join(path, '___dodai_test___')
     f = open(filename, 'w')
     f.close()
예제 #4
0
파일: base.py 프로젝트: otmsol/dodai
 def _build_project_name(self):
     """Builds the name of the project.  This also checks to insure that
     no directory exists for this project already exists.  If the
     directory already exists, a new name will be generated
     """
     project_name = self._build_random_text()
     dir = find.home_direcotry(project_name=project_name)
     if os.path.exists(dir):
         return self._build_project_name()
     else:
         self._mkdir(project_name)
         return project_name
예제 #5
0
파일: base.py 프로젝트: otmsol/dodai
    def clean_up(self):
        """This recursively removes any dodai test config directories
        """
        path = find.home_direcotry()
        dirs = []
        for name in os.listdir(path):
            if name.startswith("."):
                filepath = os.path.join(path, name)
                filename = os.path.join(filepath, '___dodai_test___')
                if os.path.exists(filename):
                    dirs.append(filepath)

        for dir in dirs:
            for root, dirs, files in os.walk(dir, topdown=False):
                for name in files:
                    os.remove(os.path.join(root, name))
                for name in dirs:
                    os.rmdir(os.path.join(root, name))
            os.rmdir(dir)