-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Now allows for downloading geckodriver for macos Fix to [Issue 10](#10) - Now includes a metadata tool to generate a generalized metadata for any raster to allow upload. Fix to [Issue 7](#7) - Changed from geeup update to init to signify initialization - Added selsetup this tool allows for setting up the gecko driver with your account incase there are issues uploading - Better error handling for selenium driver download
- Loading branch information
Showing
7 changed files
with
191 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
|
||
__author__ = 'Samapriya Roy' | ||
__email__ = '[email protected]' | ||
__version__ = '0.2.4' | ||
__version__ = '0.2.5' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from __future__ import print_function | ||
try: | ||
from osgeo import gdal | ||
except ImportError: | ||
import gdal | ||
import os | ||
import math | ||
import csv | ||
|
||
|
||
def getmeta(indir,mfile): | ||
i=1 | ||
flength=len([name for name in os.listdir(indir) if name.endswith('.tif')]) | ||
with open(mfile,'w') as csvfile: | ||
writer=csv.DictWriter(csvfile,fieldnames=["id_no", "xsize", "ysize", "pixel_resolution","num_bands"], delimiter=',') | ||
writer.writeheader() | ||
for filename in os.listdir(indir): | ||
if filename.endswith('.tif'): | ||
gtif = gdal.Open(os.path.join(indir,filename)) | ||
try: | ||
print("Processed: "+str(i)+ ' of '+str(flength), end='\r') | ||
fname=(os.path.basename(gtif.GetDescription()).split('.')[0]) | ||
xsize=(gtif.RasterXSize) | ||
ysize=(gtif.RasterYSize) | ||
ulx, xres, xskew, uly, yskew, yres = gtif.GetGeoTransform() | ||
stepper = 10.0 ** 2 | ||
res=(math.trunc(stepper * xres) / stepper) | ||
bsize=(gtif.RasterCount) | ||
with open(mfile,'a') as csvfile: | ||
writer=csv.writer(csvfile,delimiter=',',lineterminator='\n') | ||
writer.writerow([fname,xsize,ysize,res,bsize]) | ||
csvfile.close() | ||
i=i+1 | ||
except Exception as e: | ||
print(e) | ||
i=i+1 | ||
# getmeta(indir=r'C:\planet_demo\dbwater\water_mask_2017_v1', | ||
# mfile=r'C:\planet_demo\rmeta.csv') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from bs4 import BeautifulSoup | ||
import requests,csv,zipfile,os,platform,tarfile | ||
from pathlib import Path | ||
from pySmartDL import SmartDL | ||
sysinfo=platform.machine()[-2:] | ||
#comb="win"+str(sysinfo)+".zip" | ||
comb="macos.tar.gz" | ||
directory=os.path.dirname(os.path.realpath(__file__)) | ||
os.chdir(os.path.dirname(os.path.realpath(__file__))) | ||
def geckodown(directory): | ||
source=requests.get("https://github.com/mozilla/geckodriver/releases/latest").text | ||
soup=BeautifulSoup(source.encode("utf-8"),'lxml') | ||
vr=str(soup.title.text.encode("utf-8")).split(' ')[1] | ||
container="https://github.com/mozilla/geckodriver/releases/download/"+vr+"/geckodriver-"+vr+'-'+comb | ||
print("Downloading from: "+str(container)) | ||
try: | ||
url = container | ||
dest = directory | ||
obj = SmartDL(url, dest) | ||
obj.start() | ||
path=obj.get_dest() | ||
print(os.path.join(directory,'geckodriver-'+vr+'-linux64.zip')) | ||
filepath=os.path.join(directory,'geckodriver-'+vr+'-'+comb) | ||
if (filepath.endswith("tar.gz")): | ||
tar = tarfile.open(filepath,'r:*') | ||
tar.extractall(directory) | ||
tar.close() | ||
#print "Extracted in Current Directory" | ||
print("Use selenium driver path as "+os.path.join(directory,"geckodriver")) | ||
except Exception as e: | ||
print('Issues updating with error '+str(e)) | ||
|
||
geckodown(directory=directory) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import requests | ||
import time | ||
import os | ||
import getpass | ||
from selenium import webdriver | ||
|
||
|
||
pathway=os.path.dirname(os.path.realpath(__file__)) | ||
def authenticate(): | ||
authorization_url="https://code.earthengine.google.com" | ||
uname=str(raw_input("Enter your Username: ")) | ||
passw=str(getpass.getpass("Enter your Password: ")) | ||
driver = webdriver.Firefox(executable_path=os.path.join(pathway,"geckodriver.exe")) | ||
driver.get(authorization_url) | ||
time.sleep(2) | ||
try: | ||
username = driver.find_element_by_xpath('//*[@id="identifierId"]') | ||
username.send_keys(uname) | ||
driver.find_element_by_id("identifierNext").click() | ||
time.sleep(5) | ||
passw=driver.find_element_by_name("password").send_keys(passw) | ||
driver.find_element_by_id("passwordNext").click() | ||
time.sleep(5) | ||
driver.find_element_by_xpath("//div[@id='view_container']/form/div[2]/div/div/div/ul/li/div/div[2]/p").click() | ||
time.sleep(5) | ||
driver.find_element_by_xpath("//div[@id='submit_approve_access']/content/span").click() | ||
time.sleep(5) | ||
driver.find_element_by_xpath("(.//*[normalize-space(text()) and normalize-space(.)='terms of service'])[1]/following::span[2]").click() | ||
time.sleep(3) | ||
driver.find_element_by_id("profileIdentifier").click() | ||
time.sleep(2) | ||
driver.find_element_by_xpath("(.//*[normalize-space(text()) and normalize-space(.)='Earth Engine Code Editor'])[1]/following::div[13]").click() | ||
except Exception as e: | ||
pass | ||
cookies = driver.get_cookies() | ||
s = requests.Session() | ||
for cookie in cookies: | ||
s.cookies.set(cookie['name'], cookie['value']) | ||
print('\n'+'Selenium Setup complete with Google Profile') | ||
driver.close() | ||
authenticate() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters