Example #1
0
def mkdir():
    error = None
    p = request.form['p']
    dirname = request.form['dirname']
    path = '/'+p
    files.mkdir(path, dirname)
    return redirect(url_for('.file_ui', p=p))
Example #2
0
def mkdir():
    error = None
    p = request.form['p']
    dirname = request.form['dirname']
    path = '/' + p
    files.mkdir(path, dirname)
    return redirect(url_for('.file_ui', p=p))
Example #3
0
def CreateUser (username, password):
  DirectoryName = username
  f.mkdir (f.JoinPath (f.DirectoryForUsers, DirectoryName) )
  f.mkdir (f.JoinPath (f.DirectoryForUsers, DirectoryName))
  open (DirectoryForUsers + "/" + DirectoryName + "/settings.ini","w+")
  #ove  this file and create a sign in file
  PrevStartupNameAndLoc = r"startup.txt"
  NewStartupNameAndLoc = r"startup.py"
  f.rename (PrevStartupNameAndLoc ,NewStartupNameAndLoc)
Example #4
0
 def post(self, p):
     if not files.exists(p):
         abort(404, message=('File not found: %s' % p))
     o = json.load(request.stream)
     if not (isinstance(o, dict) and 'command' in o):
         abort(400)
     cmd = o['command']
     try:
         if cmd == 'move':
             if not 'to' in o:
                 abort(400)
             files.move_file(p, o['to'])
         elif cmd == 'copy':
             if not 'to' in o:
                 abort(400)
             files.copy_file(p, o['to'])
         elif cmd == 'mkdir':
             name = o['name']
             if '/' in name:
                 abort(400, message='Invalid filename.')
             if not files.is_directory(p):
                 abort(400, message='Not a directory.')
             if not 'name' in o:
                 abort(400)
             return files.mkdir(p, name)
         else:
             abort(400, message=('Invalid command: %s' % cmd))
     except OSError as e:
         abort(500, message=('File system error: ' + e.strerror))
     except IOError as e:
         abort(500, message=('File system error: ' + e.strerror))
     return '', 204
    def cache_file(cls, url, revision=None):
        """
        Caches an SVN file locally for verification.
    
        :param url: SVN URL of the file
        :type  url: basestring
        :param revision: SVN revision of the file
        :type  revision: int
        :return: the cached file
        :rtype: FileCache
        """
        if cls._cache_dir is None:
            raise CacheDirNotSet('The cache directory has not been set')

        with execute.KeyLocker.lock('cache-file-{url}-{rev}'.format(
                url=url, rev=revision)):
            existing_cache = SVNCache.get_cached_file(url, revision=revision)
            if existing_cache is not None:
                return existing_cache

            files.mkdir(cls._cache_dir)

            # generate cache path
            filename = os.path.basename(urlparse.urlparse(url).path)
            cache_path = os.path.join(
                cls._cache_dir, '{uuid}_{fname}'.format(uuid=uuid.uuid4(),
                                                        fname=filename))

            # export file
            logging.debug('Caching "{url}" at "{path}"...'.format(
                url=url, path=cache_path))

            url_exists = svn.export(url=url,
                                    path=cache_path,
                                    revision=revision)
            if not url_exists:
                raise SvnFileDoesNotExist(
                    'File does not exist at "{}"'.format(url))

            file_cache = FileCache(name=filename,
                                   url=url,
                                   revision=revision,
                                   path=cache_path)

            SVNCache.add_cached_file(file_cache)
            return file_cache
from __future__ import print_function
import os
import sys

import chainer
import numpy

from argument import get_args
from model import load_model
from files import load_image, save_features, mkdir, grep_images


if __name__ == '__main__':
    args, xp = get_args()
    forward, in_size, mean_image = load_model(args)
    mkdir(args.dst)

    msg = True
    ps = []
    path_list = grep_images(args.src)
    total = len(path_list)
    x_batch = numpy.ndarray((args.batchsize, 3, in_size, in_size), dtype=numpy.float32)

    for i, path in enumerate(path_list):
        image = load_image(path, in_size, mean_image)
        x_batch[i % args.batchsize] = image
        ps.append(path)

        if i == 0 and i != total - 1:
            continue
        if (i + 1) % args.batchsize == 0 or i == total - 1: