def main(): """ Main function. Parse command line arguments """ parser = argparse.ArgumentParser(description="A Google Play Store Apk downloader and manager for command line") parser.add_argument('-V', '--version', help="Print version number and exit", action='store_true') parser.add_argument('-v', '--verbose', help="Be verbose", action='store_true') parser.add_argument('-s', '--search', help="Search the given string in Google Play Store", metavar="SEARCH") parser.add_argument('-d', '--download', help="Download the Apps that map given AppIDs", metavar="AppID", nargs="+") parser.add_argument('-y', '--yes', help="Say yes to all prompted questions", action='store_true') parser.add_argument('-l', '--list', help="List APKS in the given folder, with details", metavar="FOLDER") parser.add_argument('-P', '--paid', help="Also search for paid apps", action='store_true', default=False) parser.add_argument('-av', '--append-version', help="Append versionstring to APKs when downloading", action='store_true') parser.add_argument('-a', '--additional-files', help="Enable the download of additional files", action='store_true', default=False) parser.add_argument('-F', '--file', help="Load packages to download from file, one package per line", metavar="FILE") parser.add_argument('-u', '--update', help="Update all APKs in a given folder", metavar="FOLDER") parser.add_argument('-f', '--folder', help="Where to put the downloaded Apks, only for -d command", metavar="FOLDER", nargs=1, default=['.']) parser.add_argument('-dc', '--device-codename', help="The device codename to fake", choices=GooglePlayAPI.getDevicesCodenames(), metavar="DEVICE_CODENAME") parser.add_argument('-t', '--token', help="Instead of classical credentials, use the tokenize version", action='store_true', default=None) parser.add_argument('-tu', '--token-url', help="Use the given tokendispenser URL to retrieve a token", metavar="TOKEN_URL") parser.add_argument('-ts', '--token-str', help="Supply token string by yourself, need to supply GSF_ID at the same time", metavar="TOKEN_STR") parser.add_argument('-g', '--gsfid', help="Supply GSF_ID by yourself, need to supply token string at the same time", metavar="GSF_ID") parser.add_argument('-c', '--config', help="Use a different config file than gplaycli.conf", metavar="CONF_FILE", nargs=1) parser.add_argument('-p', '--progress', help="Prompt a progress bar while downloading packages", action='store_true') parser.add_argument('-L', '--log', help="Enable logging of apps status in separate logging files", action='store_true', default=False) if len(sys.argv) < 2: sys.argv.append("-h") args = parser.parse_args() if args.version: print(__version__) return cli = GPlaycli(args, args.config) if args.list: print(util.list_folder_apks(args.list)) if args.update: cli.prepare_analyse_apks() return if args.search: cli.verbose = True cli.search(args.search, not args.paid) if args.file: args.download = util.load_from_file(args.file) if args.download is not None: if args.folder is not None: cli.download_folder = args.folder[0] cli.download(args.download)
def main(argv): if len(argv) != 3: print('Usage: %s <input_array.np[yz]> <output_image.png>' % (argv[0],)) sys.exit(-1) input_path = argv[1] output_path = argv[2] height, land_mask = util.load_from_file(input_path) util.save_as_png(util.hillshaded(height, land_mask=land_mask), output_path)
def main(argv): parser = argparse.ArgumentParser( description= "Generates a PNG containing the terrain height in grayscale.") parser.add_argument("input_array", help="<input_array.np[yz]> (include file extension)") parser.add_argument("output_image", help="<output_image.png> (include file extension)") args = parser.parse_args() my_dir = os.path.dirname(argv[0]) output_dir = os.path.join(my_dir, 'output') input_path = args.input_array output_path = os.path.join(output_dir, args.output_image) height, _ = util.load_from_file(input_path) util.save_as_png(height, output_path)
def createNewTask(): """Create a new task 1. Interact with user to grab the task content 2. Schedule the task 3. Put the task record in file. """ #TODO: Now the task content is not allowed to contain any coma # since I'm using coma as delimeter in schdule_task(). # This need to be imporved. task_content = raw_input('Please input task:') options = { 1: '2 Hours later', 2: 'Tomorrow Evening', 3: 'Tomorrow Morning', 4: 'Tomorrow Afternoon' } print 'Please select task scheduled time:' for i, option in options.items(): print '{}. {}'.format(i, option) while True: user_option = int(raw_input('Your Option:')) #TODO: Rerange schedule time from 1-4 if not 0 <= user_option < 4: print 'Invalid Option' continue break task_id, schedule_time = scheduleTask(user_option, task_content) #TODO: Create an LaterTask object and put it in the queue. print('[{}] will be scheduled at {}'.format(task_content, schedule_time)) task_list = load_from_file(TASK_LIST) newTask = LaterTask(task_id, schedule_time, task_content) task_list.append(newTask) save_to_file(task_list, TASK_LIST)
import constants as cnst # Make sure that caffe is on the python path: caffe_root = '~/Desktop/Projects/deep_learning/caffe/' # this file is expected to be in {caffe_root}/examples import sys sys.path.insert(0, caffe_root + 'python') import caffe # Set the right path to your model definition file, pretrained model weights, # and the image you would like to classify. MODEL_FILE = '/home/Sharad/Desktop/Projects/Major/models/caffe_model_1/deploy.prototxt' PRETRAINED = '/home/Sharad/Desktop/Projects/Major/models/caffe_model_1/snapshot/_iter_5000.caffemodel' testing_dataset = util.load_from_file('/home/Sharad/Desktop/Projects/Major/Datasets/Kaggle_preprocessed/Testingset.npy') caffe.set_mode_cpu() net = caffe.Classifier(MODEL_FILE, PRETRAINED, image_dims=(cnst.IMAGE_WIDTH, cnst.IMAGE_HEIGHT)) cnt_correct = 0 cnt_total = testing_dataset.shape[0] #Can be predicted without for-loop for i in xrange(testing_dataset.shape[0]): label = testing_dataset[i][0] image = testing_dataset[i][1] #Show image
def load_word_map(): if not os.path.isfile(WORD_MAP_FILENAME): return build_word_map() print("Loading word map...") return util.load_from_file(WORD_MAP_FILENAME)
def __get_values(self): values = util.load_from_file(self._path_values) if not(values is None) and not(self._reset_thresholds): self._ball_thresholds, self._contrasts, self._brightnesses, self._gray_thresholds = values
def __load_pitch_size(self): things = util.load_from_file(self._path_pitch_size) if not things is None: self._crop_rect, self._coord_rect = things self._all_set = True
die = True message = "The target url is malformed: " + args.target if not os.path.isfile( os.path.join(dir_path, config_file)): die = True message = "No configuration file found: " + os.path.join(dir_path, config_file) if args.time: if not args.time.isdigit(): die = True message = "Time specified not numeric" elif float(args.time) > 30 or float(args.time) < 1: die = True message = "Time specified to small or too large" config = util.load_from_file(os.path.join(dir_path,""),config_file) if not config: die = True message = "The configuration file is malformed" # TODO check whether the configuration dictionary contains the right data if die: print message sys.exit() time = default_time if args.time: time = float(args.time) print "URL Target: " + colored(target, 'cyan') + " Visiting for " + colored(str(time),'cyan') + " sec"
def __from_file(self): return util.load_from_file(self.file)
message = "The target url is malformed: " + args.target if not os.path.isfile(os.path.join(dir_path, config_file)): die = True message = "No configuration file found: " + \ os.path.join(dir_path, config_file) if args.time: if not args.time.isdigit(): die = True message = "Time specified not numeric" elif float(args.time) > 30 or float(args.time) < 1: die = True message = "Time specified to small or too large" config = util.load_from_file(os.path.join(dir_path, ""), config_file) if not config: die = True message = "The configuration file is malformed" # TODO check whether the configuration dictionary contains the right data if die: print(message) sys.exit() time = default_time if args.time: time = float(args.time) with open(url_list, 'r') as f:
# -*- coding: utf-8 -*- from __future__ import unicode_literals import sys reload(sys) sys.setdefaultencoding("utf-8") import requests import json import traceback import logging from util import load_from_file, save_to_file addresses = load_from_file('address.json', {}) urls = load_from_file('urls.json', {}) log_google = logging.getLogger('goog') def get_address(latitude, longitude, googlemaps_api_key, force=True, no_cache=False): latlng = '{0},{1}'.format(latitude, longitude) if latlng in addresses: return addresses[latlng]['results'][0]['formatted_address'] if no_cache: try: url = "https://maps.googleapis.com/maps/api/geocode/json?latlng={lat},{lng}&key={api_key}".format( lat=latitude, lng=longitude, api_key=googlemaps_api_key ) log_google.info('Buscando endereco {0},{1} (Google Maps API)...'.format(latitude, longitude)) raw_data = requests.get(url) data = json.loads(raw_data.text) log_google.info('Endereco obtido.')