예제 #1
0
 def on_create(self):
     self.verify()
     try:
         util.mkdirp(self.prefix)
     except:
         raise ConfigurationError('Cannot create directory %r' % self.prefix,
                                  'Check that you have `write` access')
예제 #2
0
 def on_create(self):
     self.verify()
     try:
         util.mkdirp(self.prefix)
     except:
         raise ConfigurationError('Cannot create directory %r' % self.prefix,
                                  'Check that you have `write` access')
예제 #3
0
 def on_create(self):
     try:
         util.mkdirp(self.prefix)
     except Exception as err:
         raise ConfigurationError(
             'Cannot create directory %r: %s' % (self.prefix, err),
             'Check that you have write access')
예제 #4
0
 def connect_filesystem(self, *args, **kwargs):
     """Prepares the store filesystem for reading and writing."""
     if not os.path.isdir(self._prefix):
         try:
             util.mkdirp(self._prefix)
         except Exception as err:
             raise StorageError("Failed to access %s filesystem prefix '%s': %s" % (self.name, self._prefix, err))
         LOGGER.debug("Initialized %s filesystem prefix '%s'", self.name, self._prefix)
예제 #5
0
 def connect_filesystem(self, *args, **kwargs):
     """Prepares the store filesystem for reading and writing."""
     if not os.path.isdir(self._prefix):
         try:
             util.mkdirp(self._prefix)
         except Exception as err:
             raise StorageError("Failed to access %s filesystem prefix '%s': %s" % (self.name, self._prefix, err))
         LOGGER.debug("Initialized %s filesystem prefix '%s'", self.name, self._prefix)
예제 #6
0
 def connect_database(self, *args, **kwargs):
     """Open the database for reading and writing."""
     if self._database is None:
         util.mkdirp(self.prefix)
         dbfile = os.path.join(self.prefix, self.name + '.json')
         try:
             self._database = tinydb.TinyDB(dbfile, storage=_JsonFileStorage)
         except IOError as err:
             raise StorageError("Failed to access %s database '%s': %s" % (self.name, dbfile, err),
                                "Check that you have `write` access")
         if not util.path_accessible(dbfile):
             raise StorageError("Database file '%s' exists but cannot be read." % dbfile,
                                "Check that you have `read` access")
         LOGGER.debug("Initialized %s database '%s'", self.name, dbfile)
예제 #7
0
 def generate_wrapper(self, prefix):
     """Generate a compiler wrapper script that uses :any:`taucmdr.TAUCMDR_SCRIPT` to invoke the compiler.
     
     Args:
         prefix (str): Path to a directory in which the wrapper script will be created.
     """
     script_file = os.path.join(prefix, '%s_%s' % (os.path.basename(TAUCMDR_SCRIPT), self.command))
     util.mkdirp(prefix)
     with open(script_file, "w+") as fout:
         wrapper = _COMPILER_WRAPPER_TEMPLATE % {'date': str(datetime.now()),
                                                 'user': getpass.getuser(),
                                                 'taucmdr_script': TAUCMDR_SCRIPT,
                                                 'command': self.command}
         fout.write(wrapper)
     os.chmod(script_file, os.stat(script_file).st_mode | 0111)
예제 #8
0
 def generate_wrapper(self, prefix):
     """Generate a compiler wrapper script that uses :any:`tau.TAUCMDR_SCRIPT` to invoke the compiler.
     
     Args:
         prefix (str): Path to a directory in which the wrapper script will be created.
     """
     script_file = os.path.join(prefix, '%s_%s' % (TAUCMDR_SCRIPT, self.command))
     util.mkdirp(prefix)
     with open(script_file, "w+") as fout:
         wrapper = _COMPILER_WRAPPER_TEMPLATE % {'date': str(datetime.now()),
                                                 'user': getpass.getuser(),
                                                 'taucmdr_script': TAUCMDR_SCRIPT,
                                                 'command': self.command}
         fout.write(wrapper)
     os.chmod(script_file, os.stat(script_file).st_mode | 0111)
예제 #9
0
 def connect_database(self, *args, **kwargs):
     """Open the database for reading and writing."""
     if self._database is None:
         util.mkdirp(self.prefix)
         dbfile = os.path.join(self.prefix, self.name + '.json')
         try:
             storage = CachingMiddleware(_JsonFileStorage)
             storage.WRITE_CACHE_SIZE = 0
             self._database = tinydb.TinyDB(dbfile, storage=storage)
         except IOError as err:
             raise StorageError("Failed to access %s database '%s': %s" % (self.name, dbfile, err),
                                "Check that you have `write` access")
         if not util.path_accessible(dbfile):
             raise StorageError("Database file '%s' exists but cannot be read." % dbfile,
                                "Check that you have `read` access")
         LOGGER.debug("Initialized %s database '%s'", self.name, dbfile)
예제 #10
0
 def connect_filesystem(self, *args, **kwargs):
     """Prepares the store filesystem for reading and writing."""
     from taucmdr.cf.storage.levels import USER_STORAGE
     try:
         project_prefix = self.prefix
     except ProjectStorageError:
         project_prefix = os.path.join(os.getcwd(), PROJECT_DIR)
         if os.path.exists(os.path.join(project_prefix, USER_STORAGE.name + ".json")):
             raise StorageError("Cannot create project in home directory. "
                                "Use '-@ user' option for user level storage.")
         try:
             util.mkdirp(project_prefix)
         except Exception as err:
             raise StorageError("Failed to access %s filesystem prefix '%s': %s" %
                                (self.name, project_prefix, err))
         # Exclude project storage directory from git
         with open(os.path.join(self.prefix, '.gitignore'), 'w+') as fout:
             fout.write('/*\n')
         LOGGER.debug("Initialized %s filesystem prefix '%s'", self.name, project_prefix)
예제 #11
0
 def run(self):
     from taucmdr import util
     InstallCommand.run(self)
     util.mkdirp(os.path.join(self.prefix, 'system'))
     shutil.move(os.path.join(self.prefix, 'bin', 'system_configure'),
                 os.path.join(self.prefix, 'system', 'configure'))
예제 #12
0
 def run(self):
     from taucmdr import util
     InstallCommand.run(self)
     util.mkdirp(os.path.join(self.prefix, 'system'))
     shutil.move(os.path.join(self.prefix, 'bin', 'system_configure'),
                 os.path.join(self.prefix, 'system', 'configure'))
예제 #13
0
 def on_create(self):
     try:
         util.mkdirp(self.prefix)
     except Exception as err:
         raise ConfigurationError('Cannot create directory %r: %s' % (self.prefix, err),
                                  'Check that you have write access')