You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2013/08/01 20:30:23 UTC
[11/22] git commit: Remove CLI stuff since it will be part of a
separate PR.
Remove CLI stuff since it will be part of a separate PR.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/e6436559
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/e6436559
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/e6436559
Branch: refs/heads/0.13.x
Commit: e64365592bf63ac7b826ce1c3685bd417eef97ec
Parents: 11db737
Author: Tomaz Muraus <to...@tomaz.me>
Authored: Wed Jul 31 19:48:37 2013 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Thu Aug 1 20:28:49 2013 +0200
----------------------------------------------------------------------
bin/libcloud | 30 ----------------
libcloud/cli/__init__.py | 0
libcloud/cli/pricing.py | 84 -------------------------------------------
3 files changed, 114 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/e6436559/bin/libcloud
----------------------------------------------------------------------
diff --git a/bin/libcloud b/bin/libcloud
deleted file mode 100755
index 270922e..0000000
--- a/bin/libcloud
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/env python
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from __future__ import with_statement
-
-import argparse
-
-from libcloud.cli.pricing import add_subparser, update_pricing
-
-parser = argparse.ArgumentParser(prog='libcloud', usage='%(prog)s')
-subparsers = parser.add_subparsers(dest='subparser_name')
-add_subparser(subparsers=subparsers)
-
-args = parser.parse_args()
-
-if args.subparser_name == 'update-pricing':
- update_pricing(file_url=args.file_url, file_path=args.file_path)
http://git-wip-us.apache.org/repos/asf/libcloud/blob/e6436559/libcloud/cli/__init__.py
----------------------------------------------------------------------
diff --git a/libcloud/cli/__init__.py b/libcloud/cli/__init__.py
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/libcloud/blob/e6436559/libcloud/cli/pricing.py
----------------------------------------------------------------------
diff --git a/libcloud/cli/pricing.py b/libcloud/cli/pricing.py
deleted file mode 100644
index 584d292..0000000
--- a/libcloud/cli/pricing.py
+++ /dev/null
@@ -1,84 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import os
-import sys
-
-try:
- import simplejson as json
-except ImportError:
- import json
-
-
-from libcloud.pricing import CUSTOM_PRICING_FILE_PATH
-from libcloud.utils.connection import get_response_object
-
-__all__ = [
- 'add_subparser',
- 'update_pricing'
-]
-
-# Default URL to the pricing file
-DEFAULT_FILE_URL = 'https://git-wip-us.apache.org/repos/asf?p=libcloud.git;a=blob_plain;f=libcloud/data/pricing.json'
-
-
-def add_subparser(subparsers):
- parser = subparsers.add_parser('update-pricing',
- help='Update Libcloud pricing file')
- parser.add_argument('--file-path', dest='file_path', action='store',
- default=CUSTOM_PRICING_FILE_PATH,
- help='Path where the file will be saved')
- parser.add_argument('--file-url', dest='file_url', action='store',
- default=DEFAULT_FILE_URL,
- help='URL to the pricing file')
- return parser
-
-
-def update_pricing(file_url, file_path):
- dir_name = os.path.dirname(file_path)
-
- if not os.path.exists(dir_name):
- # Verify a valid path is provided
- sys.stderr.write('Can\'t write to %s, directory %s, doesn\'t exist\n' %
- (file_path, dir_name))
- sys.exit(2)
-
- if os.path.exists(file_path) and os.path.isdir(file_path):
- sys.stderr.write('Can\'t write to %s file path because it\'s a'
- ' directory\n' %
- (file_path))
- sys.exit(2)
-
- response = get_response_object(file_url)
- body = response.body
-
- # Verify pricing file is valid
- try:
- data = json.loads(body)
- except json.decoder.JSONDecodeError:
- sys.stderr.write('Provided URL doesn\'t contain valid pricing'
- ' data\n')
- sys.exit(3)
-
- if not data.get('updated', None):
- sys.stderr.write('Provided URL doesn\'t contain valid pricing'
- ' data\n')
- sys.exit(3)
-
- # No need to stream it since file is small
- with open(file_path, 'w') as file_handle:
- file_handle.write(response.body)
-
- print('Pricing file saved to %s' % (file_path))