def write(self, content):
     try:
         with open(self._file_path, "w+") as out_file:
             out_file.write(content)
     except:
         print("Unexpected error at {}.write: {}".format(
             __name__, sys.exc_info()))
     else:
         print(
             "Content of size {} has been written to {} by {} at {}".format(
                 sizeof_fmt(content), self._file_path, __name__,
                 datetime.now().strftime(app.config['DATETIME_FORMAT'])))
 def write(self, content):
     try:
         self._blob_service.create_blob_from_text(self._container_name,
                                                  self._file_path, content)
     except:
         print("Unexpected error at {}.write: {}".format(
             __name__, sys.exc_info()))
     else:
         print(
             "Content of size {} has been written to {} by {} at {}".format(
                 sizeof_fmt(content), self._file_path, __name__,
                 datetime.now().strftime(app.config['DATETIME_FORMAT'])))
Ejemplo n.º 3
0
 def _helper(name, filetype):
     return {
         'filepath': os.path.join(self.path, name),
         'filetype': filetype,
         'filename': name,
         'filedate': STORAGE.get_modified_time(os.path.join(self.path, name)),
         'filesize': sizeof_fmt(STORAGE.size(os.path.join(self.path, name))),
         'fileurl' : os.path.join(settings.MEDIA_URL, self.abspath, name),
         'link': app.models.Files.objects.get(location=os.path.join(self.path, name)).link,
         'blocked': app.models.Files.objects.get(location=os.path.join(self.path, name)).blocked,
         'url_access': app.models.Files.objects.get(location=os.path.join(self.path, name)).url_access,
         'allowed_urls': app.models.Files.objects.get(location=os.path.join(self.path, name)).allowed_urls,
     }
Ejemplo n.º 4
0
 def _helper(name, filetype):
     return {
         'filepath': os.path.join(location, name),
         'filetype': filetype,
         'filename': name,
         'filedate': STORAGE.get_modified_time(os.path.join(location, name)),
         'filesize': sizeof_fmt(STORAGE.size(os.path.join(location, name))),
         'fileurl': os.path.join(app.settings.MEDIA_URL, location, name),
         'link': link,
         'blocked': app.models.Files.objects.get(link='sharewood.cloud/public/{}'.format(link)).blocked,
         'url_access': app.models.Files.objects.get(link='sharewood.cloud/public/{}'.format(link)).url_access,
         'allowed_urls': app.models.Files.objects.get(link='sharewood.cloud/public/{}'.format(link)).allowed_urls,
     }
Ejemplo n.º 5
0
 def file_details(self):
     filename = self.path.rsplit('/', 1)[-1]
     return {
         'directory': os.path.dirname(self.path),
         'filepath': self.path,
         'filename': filename,
         'filesize': sizeof_fmt(STORAGE.size(self.location)),
         'filedate': STORAGE.get_modified_time(self.location),
         'fileurl': self.url,
         'link':  app.models.Files.objects.get(location=os.path.join(self.path, filename)).link,
         'blocked': app.models.Files.objects.get(location=os.path.join(self.path, filename)).blocked,
         'url_access': app.models.Files.objects.get(location=os.path.join(self.path, filename)).url_access,
         'allowed_urls': app.models.Files.objects.get(location=os.path.join(self.path, filename)).allowed_urls,
     }