# Path: historisation/historisation/storage.py
# class Storage(object):
#     # returns a string with the content of the file or None if it does not exist.
#     def get(self, path):
#         pass
# 
#     # returns true if the file exists
#     def exists(self, path):
#         pass
# 
#     # saves a file-like object at the given location
#     def save(self, path, file):
#         pass
# 
#     # returns a list of directories from the root
#     def get_dirs(self):
#         pass
# 
#     # returns the files from a given directory
#     def get_files(self, path):
#         pass
# 
#     # creates a new directory
#     def mkdir(self, path):
#         pass
# 
#     # moves
#     def move(self, source, dest):
#         pass
# 
#     # join
#     def join(self, *paths):
#         pass


from ftplib import FTP, error_perm, all_errors, error_temp
from ..storage import Storage
import io
import logging
        try:
            ftp.mkd(path)
        except error_perm:
            pass

    def get_dirs(self):
        ftp = self._get_ftp()
        return ftp.nlst()

    def get_files(self, path):
        ftp = self._get_ftp()
        return [file_path.split('/')[-1] for file_path in ftp.nlst(path)]

    def join(self, *paths):
        return '/'.join(paths)

    def move(self, source, dest):
        ftp = self._get_ftp()
        ftp.rename(source, dest)

    def _get_ftp(self):
        if not self._ftp:
            return self._get_new_ftp()

        try:
            self._ftp.cwd(self.root_dir)
            return self._ftp
        except all_errors:
            return self._get_new_ftp()


# Path: historisation/historisation/storage.py
# class Storage(object):
#     # returns a string with the content of the file or None if it does not exist.
#     def get(self, path):
#         pass
# 
#     # returns true if the file exists
#     def exists(self, path):
#         pass
# 
#     # saves a file-like object at the given location
#     def save(self, path, file):
#         pass
# 
#     # returns a list of directories from the root
#     def get_dirs(self):
#         pass
# 
#     # returns the files from a given directory
#     def get_files(self, path):
#         pass
# 
#     # creates a new directory
#     def mkdir(self, path):
#         pass
# 
#     # moves
#     def move(self, source, dest):
#         pass
# 
#     # join
#     def join(self, *paths):
#         pass


# Path: historisation/historisation/storages/ftp.py
from ftplib import FTP, error_perm, all_errors, error_temp
from ..storage import Storage
import io
import logging

        try:
            ftp.mkd(path)
        except error_perm:
            pass

    def get_dirs(self):
        ftp = self._get_ftp()
        return ftp.nlst()

    def get_files(self, path):
        ftp = self._get_ftp()
        return [file_path.split('/')[-1] for file_path in ftp.nlst(path)]

    def join(self, *paths):
        return '/'.join(paths)

    def move(self, source, dest):
        ftp = self._get_ftp()
        ftp.rename(source, dest)

    def _get_ftp(self):
        if not self._ftp:
            return self._get_new_ftp()

        try:
            self._ftp.cwd(self.root_dir)
            return self._ftp
        except all_errors:
            return self._get_new_ftp()


    def _get_new_ftp(self):