| tierno | 87858ca | 2018-10-08 16:30:15 +0200 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | |
| 3 | # Copyright 2018 Telefonica S.A. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 14 | # implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | |
| tierno | 5c01261 | 2018-04-19 16:01:59 +0200 | [diff] [blame] | 18 | |
| 19 | from http import HTTPStatus |
| 20 | |
| 21 | __author__ = "Alfonso Tierno <alfonso.tiernosepulveda@telefonica.com>" |
| 22 | |
| 23 | |
| 24 | class FsException(Exception): |
| 25 | def __init__(self, message, http_code=HTTPStatus.INTERNAL_SERVER_ERROR): |
| 26 | self.http_code = http_code |
| 27 | Exception.__init__(self, "storage exception " + message) |
| 28 | |
| 29 | |
| 30 | class FsBase(object): |
| 31 | def __init__(self): |
| 32 | pass |
| 33 | |
| 34 | def get_params(self): |
| 35 | return {} |
| 36 | |
| 37 | def fs_connect(self, config): |
| 38 | pass |
| 39 | |
| 40 | def fs_disconnect(self): |
| 41 | pass |
| 42 | |
| 43 | def mkdir(self, folder): |
| tierno | ebbf353 | 2018-05-03 17:49:37 +0200 | [diff] [blame] | 44 | raise FsException("Method 'mkdir' not implemented") |
| tierno | 5c01261 | 2018-04-19 16:01:59 +0200 | [diff] [blame] | 45 | |
| 46 | def file_exists(self, storage): |
| tierno | ebbf353 | 2018-05-03 17:49:37 +0200 | [diff] [blame] | 47 | raise FsException("Method 'file_exists' not implemented") |
| tierno | 5c01261 | 2018-04-19 16:01:59 +0200 | [diff] [blame] | 48 | |
| 49 | def file_size(self, storage): |
| tierno | ebbf353 | 2018-05-03 17:49:37 +0200 | [diff] [blame] | 50 | raise FsException("Method 'file_size' not implemented") |
| tierno | 5c01261 | 2018-04-19 16:01:59 +0200 | [diff] [blame] | 51 | |
| 52 | def file_extract(self, tar_object, path): |
| tierno | ebbf353 | 2018-05-03 17:49:37 +0200 | [diff] [blame] | 53 | raise FsException("Method 'file_extract' not implemented") |
| tierno | 5c01261 | 2018-04-19 16:01:59 +0200 | [diff] [blame] | 54 | |
| 55 | def file_open(self, storage, mode): |
| tierno | ebbf353 | 2018-05-03 17:49:37 +0200 | [diff] [blame] | 56 | raise FsException("Method 'file_open' not implemented") |
| tierno | 5c01261 | 2018-04-19 16:01:59 +0200 | [diff] [blame] | 57 | |
| 58 | def file_delete(self, storage, ignore_non_exist=False): |
| tierno | ebbf353 | 2018-05-03 17:49:37 +0200 | [diff] [blame] | 59 | raise FsException("Method 'file_delete' not implemented") |