aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLionel <lionel.miquel46@gmail.com>2019-02-02 20:19:16 +0100
committerLionel <lionel.miquel46@gmail.com>2019-02-02 20:19:16 +0100
commit9ae6167d9b7ce53a273c46cf96cc73aaefb167f9 (patch)
tree98bc395eea7f574ce78193b849b2a881a19b6c33
parentf86db56f16896ef59be270526c090893809beae4 (diff)
downloadrandopitons-9ae6167d9b7ce53a273c46cf96cc73aaefb167f9.tar.gz
randopitons-9ae6167d9b7ce53a273c46cf96cc73aaefb167f9.zip
Deleted _config.yml, no use for it now
-rwxr-xr-x.README.md.swpbin0 -> 12288 bytes
-rwxr-xr-x[-rw-r--r--].gitignore0
-rwxr-xr-x.randopitons.sh.swpbin0 -> 20480 bytes
-rwxr-xr-x[-rw-r--r--]LICENSE0
-rwxr-xr-x[-rw-r--r--]README.md0
-rwxr-xr-x__init__.py0
-rw-r--r--_config.yml1
-rwxr-xr-xalgo.txt0
-rwxr-xr-xcookiejar.txt5
-rwxr-xr-xmatched.txt3
-rwxr-xr-xnohup.out0
-rwxr-xr-xprototyping/__init__.py0
-rwxr-xr-xprototyping/colorcode.py22
-rwxr-xr-xprototyping/errmsg.py7
-rwxr-xr-xprototyping/foldercreating.py82
-rwxr-xr-xprototyping/inputs.py69
-rwxr-xr-xprototyping/main.py46
-rwxr-xr-xprototyping/mapsparsing.py27
-rwxr-xr-xprototyping/randoweb.py133
-rw-r--r--randopitons.754
-rwxr-xr-x[-rw-r--r--]randopitons.7.gzbin466 -> 466 bytes
-rwxr-xr-x[-rw-r--r--]randopitons.sh2
-rwxr-xr-xregions.txt10
-rwxr-xr-xwebregions.txt9
24 files changed, 414 insertions, 56 deletions
diff --git a/.README.md.swp b/.README.md.swp
new file mode 100755
index 0000000..aab92eb
--- /dev/null
+++ b/.README.md.swp
Binary files differ
diff --git a/.gitignore b/.gitignore
index e4b1fcd..e4b1fcd 100644..100755
--- a/.gitignore
+++ b/.gitignore
diff --git a/.randopitons.sh.swp b/.randopitons.sh.swp
new file mode 100755
index 0000000..6cf01b4
--- /dev/null
+++ b/.randopitons.sh.swp
Binary files differ
diff --git a/LICENSE b/LICENSE
index e62ec04..e62ec04 100644..100755
--- a/LICENSE
+++ b/LICENSE
diff --git a/README.md b/README.md
index 7d1f1ff..7d1f1ff 100644..100755
--- a/README.md
+++ b/README.md
diff --git a/__init__.py b/__init__.py
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/__init__.py
diff --git a/_config.yml b/_config.yml
deleted file mode 100644
index 2f7efbe..0000000
--- a/_config.yml
+++ /dev/null
@@ -1 +0,0 @@
-theme: jekyll-theme-minimal \ No newline at end of file
diff --git a/algo.txt b/algo.txt
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/algo.txt
diff --git a/cookiejar.txt b/cookiejar.txt
new file mode 100755
index 0000000..aafd764
--- /dev/null
+++ b/cookiejar.txt
@@ -0,0 +1,5 @@
+# HTTP cookie file.
+# Generated by Wget on 2018-11-05 14:28:38.
+# Edit at your own risk.
+
+randopitons.re FALSE / FALSE 1551936517 randop_sess 42ab9339cc2f39b51269fc1e40cce9f29a726c8d
diff --git a/matched.txt b/matched.txt
new file mode 100755
index 0000000..21fbd22
--- /dev/null
+++ b/matched.txt
@@ -0,0 +1,3 @@
+Cirque de Cilaos
+Cirque de Mafate
+Cirque de Salazie
diff --git a/nohup.out b/nohup.out
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/nohup.out
diff --git a/prototyping/__init__.py b/prototyping/__init__.py
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/prototyping/__init__.py
diff --git a/prototyping/colorcode.py b/prototyping/colorcode.py
new file mode 100755
index 0000000..e120109
--- /dev/null
+++ b/prototyping/colorcode.py
@@ -0,0 +1,22 @@
+# coding: utf-8
+#Simplified color codes here for error/warning/ok and the such.. messages
+#
+#class Colorcode:
+# def __init__(self):
+# self.endcolor='\033[0m'
+# self.bold='\033[1m'
+# self.header='\033[95m'
+# self.okblue='\033[94m'
+# self.okgreen='\033[92m'
+# self.warn='\033[93m'
+# self.fail='\033[91m'
+# self.underline='\033[4m'
+
+endc='\033[0m'
+bold='\033[1m'
+head='\033[95m'
+okblue='\033[94m'
+okgreen='\033[92m'
+warn='\033[93m'
+fail='\033[91m'
+underline='\033[4m'
diff --git a/prototyping/errmsg.py b/prototyping/errmsg.py
new file mode 100755
index 0000000..8e67d42
--- /dev/null
+++ b/prototyping/errmsg.py
@@ -0,0 +1,7 @@
+import colorcode as clc
+os=clc.fail+"Operating System error:"+clc.endc
+direxist=clc.warn+clc.bold+"The folder already exists !"+clc.endc
+formaterr=clc.fail+"Something occured with the formating. File is not retrievable, passing on next download."+clc.endc
+sslerr=clc.fail+clc.bold+"SSL Certificate Error. Please check the time on your computer, adjust it accordingly, or wait a bit before retrying the downloads."+clc.endc
+sigkill=clc.fail+"\n\nProcess interrupted by CTRL+C or system."+clc.endc
+"\n\nProcess interrupted by CTRL+C or system."
diff --git a/prototyping/foldercreating.py b/prototyping/foldercreating.py
new file mode 100755
index 0000000..489d588
--- /dev/null
+++ b/prototyping/foldercreating.py
@@ -0,0 +1,82 @@
+import subprocess
+import os
+import time
+import colorcode as clc
+import errmsg as e
+import randoweb as rdo
+#global foldernames
+
+thehome=os.path.expanduser("~")
+defoldername="/Randopitons"
+def_folder=thehome+defoldername
+a_folder=0
+
+
+
+
+def defolder():
+ try:
+ print "\nCreating default folder "+def_folder+" ..."
+ os.mkdir(def_folder)
+ except OSError,er:
+ print e.os
+ print format(er)
+
+def mainfolder():
+ try:
+ a_folder=input("\n\nWhich folder would you want to download the files to [Default to home directory "+def_folder+"]")
+ os.mkdir(a_folder)
+ print "Folder "+a_folder+" was created successfully"
+ except OSError, er:
+ #errors out if folder exists else print the error (can be permissions or anything else)
+ if e.errno != os.errno.EEXIST:
+ raise
+ else:
+ print e.os
+ print format(er)
+ pass
+
+ except SyntaxError:
+ os.mkdir(def_folder)
+ except KeyboardInterrupt:
+ print e.sigkill
+ except:
+ raise
+
+def mkfolder(MAIL,PSW,regionnames,foldernames,maptype,ptr,bfn):
+
+ try:
+ if a_folder==0:
+ os.mkdir(os.path.join(def_folder,foldernames[ptr]))
+ else:
+ os.mkdir(os.path.join(a_folder,foldernames[ptr]))
+ #rdo.testalakon()
+ rdo.randoweb(MAIL,PSW,regionnames[ptr],maptype,bfn,def_folder+a_str)
+ except OSError, er:
+ print e.os
+ print format(er)
+
+
+def mkallfolder(MAIL,PSW,regionnames,foldernames,maptype,bfn):
+ iii=0
+ a_str="str"
+ try:
+ for a_str in foldernames:
+ if a_folder==0:
+ os.mkdir(os.path.join(def_folder,a_str))
+ else:
+ os.mkdir(os.path.join(a_folder,a_str))
+
+
+ try:
+ print "on attaque par le "+regionnames[iii]
+ rdo.randoweb(MAIL,PSW,regionnames[iii],maptype,bfn,def_folder+a_str)
+ except:
+ raise
+ iii=iii+1
+ #subprocess.call("rm -d "+fullpath)
+ print "All folders were created successfully"
+ except OSError, er:
+ print e.os
+ print format(er)
+
diff --git a/prototyping/inputs.py b/prototyping/inputs.py
new file mode 100755
index 0000000..3b47bef
--- /dev/null
+++ b/prototyping/inputs.py
@@ -0,0 +1,69 @@
+import getpass
+import colorcode as clc
+import errmsg as e
+
+
+def mapfileinput():
+ maptype = 0
+ print clc.bold+"\n Which map file extension you would want to download ?"+clc.endc
+ print """
+ 1. gpx (GPS Exchange Format)
+ 2. trk (CompeGPS Land Track File)
+ 3. kml (Keyhole Markup Language)\n"""
+
+ while maptype<1 or maptype>3:
+ try:
+ maptype = input("You must enter a number between 1 and 3. Your choice ? ")
+ int(maptype)
+ except (KeyboardInterrupt, SystemExit):
+ print e.sigkill
+ exit()
+ except SyntaxError:
+ print "Defaulting to gpx. If this isn't what you wanted, you can always interrupt the script by pressing "+clc.bold+clc.okblue+"CTRL+C"+clc.endc
+ maptype=1
+ return maptype
+
+
+def regioninput():
+ zone = 0
+ print clc.bold+"\n Which zone you would want to download ?"+clc.endc
+ print """
+ 1. Cirque de Cilaos (Cilaos Circus)
+ 2. Cirque de Mafate (Mafate's Circus)
+ 3. Cirque de Salazie (Salazie's Circus)
+ 4. Est (East)
+ 5. Nord (North)
+ 6. Ouest (West)
+ 7. Sud (South)
+ 8. Volcan (Volcano)
+ 9. Ailleurs (Elsewhere)
+ 10. All \n"""
+
+ while zone < 1 or zone > 10:
+ try:
+ zone = input("You must enter a number between 1 and 10. Your zone [Default is \"All\"]: ")
+ int(zone)
+ except (KeyboardInterrupt, SystemExit):
+ print e.sigkill
+ exit()
+ except SyntaxError:
+ print("\nDefaulting to All. If this isn't what you wanted, you can always interrupt the script by pressing "+clc.bold+clc.okblue+"CTRL+C"+clc.endc)
+ zone = 10;
+ except NameError:
+ print "\nPlease enter a number between 1 and 10."
+ zone = 0
+ return zone
+
+def loginmail():
+ try:
+ MAIL=raw_input("Your email to log in to randopitons.re : ")
+ except KeyboardInterrupt:
+ print e.sigkill
+ return MAIL
+
+def loginpass():
+ try:
+ PSW=getpass.getpass(prompt="Your password to log in to randopitons.re: ")
+ except KeyboardInterrupt:
+ print e.sigkill
+ return PSW
diff --git a/prototyping/main.py b/prototyping/main.py
new file mode 100755
index 0000000..56f04d6
--- /dev/null
+++ b/prototyping/main.py
@@ -0,0 +1,46 @@
+import os
+import inputs as io
+
+import colorcode as clc
+foldernames=["Cirque de Cilaos","Cirque de Mafate","Cirque de Salazie","Est","Nord","Ouest","Sud","Volcan","Ailleurs","All"]
+webregionnames=[]
+for i in range(9):
+ try:
+ leftside=foldernames[i].split(' ')[0].lower()+"-"
+ rightside=foldernames[i].split(' ')[2].lower()
+ webregionnames.append(leftside+rightside)
+ except IndexError,ierr:
+ oneside=foldernames[i].split(' ')[0].lower()
+ webregionnames.append(oneside)
+ pass
+import foldercreating as fdc
+basicfilename=""
+
+print clc.bold+"*************************************************************************************************************"
+print clc.bold+"* Welcome ! *"+clc.endc
+print clc.bold+"* With this script, you will be able to download gpx,trk and kml traces for hitchiking on the Reunion Isle. *"+clc.endc
+print clc.bold+"*************************************************************************************************************"
+zonechoice=io.regioninput()
+zoneptr=zonechoice-1
+maptype=io.mapfileinput()
+MAIL=io.loginmail()
+PSW=io.loginpass()
+
+
+
+if maptype==1:
+ basicfilename="f.gpx"
+elif maptype==2:
+ basicfilename="f.trk"
+elif maptype==3:
+ basicfilename="f.kml"
+
+fdc.mainfolder()
+if zonechoice == 10:
+ fdc.mkallfolder(MAIL,PSW,webregionnames,foldernames,maptype,basicfilename)
+else:
+ fdc.mkfolder(MAIL,PSW,webregionnames,foldernames,maptype,zoneptr,basicfilename)
+
+
+
+
diff --git a/prototyping/mapsparsing.py b/prototyping/mapsparsing.py
new file mode 100755
index 0000000..6caa37a
--- /dev/null
+++ b/prototyping/mapsparsing.py
@@ -0,0 +1,27 @@
+import xml.etree.ElementTree as xmlp
+import re
+import errmsg as reeee
+import os
+def mapparsing(maptype,basicfilename):
+ try:
+ tree=xmlp.parse(basicfilename)
+ root=tree.getroot()
+ if maptype==1:
+ filename=root[1][0].text+".gpx"
+ elif maptype==2:
+ thefile=open(basicfilename)
+ for i in range(3):
+ thefile.readline()
+ filename=re.findall(r'\|(.*?)\|', thefile.readline())[0]+".trk"
+ elif maptype==3:
+ filename= root[0][10][1][0].text+".kml"
+ os.rename(basicfilename,filename)
+ except OSError, e:
+ print reeee.os
+ except xmlp.ParseError, er:
+ print reeee.formaterr
+ print format(er)
+ os.remove(basicfilename)
+ pass
+
+
diff --git a/prototyping/randoweb.py b/prototyping/randoweb.py
new file mode 100755
index 0000000..57fd7f3
--- /dev/null
+++ b/prototyping/randoweb.py
@@ -0,0 +1,133 @@
+# -*- coding: utf-8 -*-
+from requests import session
+import inputs
+from bs4 import BeautifulSoup as bs
+import colorcode as clc
+import errmsg as e
+import os
+import mapsparsing as mpp
+randonb=[]
+a_str="eh"
+baseurl='https://randopitons.re/randonnee/'
+
+def filei(dwnld,fpath):
+ try:
+ f=open(fpath,'a+')
+ gudencoding=dwnld.text.encode('utf-8')
+ f.write(gudencoding)
+ f.close()
+ except:
+ raise
+
+
+
+def testalakon():
+ payload = {
+ 'mail': 'lionel.miquel46@gmail.com',
+ 'password': 'VEobWylvUdToab8'
+ }
+ with session() as c:
+ try:
+ c.post('https://randopitons.re/connexion', data=payload)
+ regionpage = c.get('https://randopitons.re/randonnees/region/cirque-cilaos')
+ try:
+ wsite=bs(regionpage.text, "lxml")
+ print "Voici les donnees:"+regionpage.text
+ except:
+ raise
+ try:
+ for i in wsite.find_all('tr'):
+ randonb.append(i.get("rid"))
+ try:
+ randonb.pop(0)
+ print "POPPED"
+ except:
+ raise
+ print "Voici les numéros de randos:"
+ print randonb
+ try:
+ for i in randonb:
+ print clc.okgreen+"Maybe downloading "+baseurl+i+'/trace/gpx'
+ try:
+ dwnld = c.get(baseurl+i+'/trace/gpx')
+ except:
+ raise
+ filei(dwnld,'/home/lili/Randopitons/Cirque de Cilaos/f-'+i+'.gpx')
+ except:
+ raise
+ except:
+ raise
+ except:
+ raise
+
+def randoweb(MAIL,PSW,region,maptype,bfn,folderpath):
+ payload = {
+ 'mail': MAIL,
+ 'password': PSW
+ }
+
+ with session() as c:
+
+ try:
+ c.post('https://randopitons.re/connexion', data=payload)
+ regionpage = c.get('https://randopitons.re/randonnees/region/'+region)
+ try:
+ wsite=bs(regionpage.text, "lxml")
+ print "Voici les donnees:"+regionpage.text
+ except:
+ raise
+ try:
+ for i in wsite.find_all('tr'):
+ randonb.append(i.get("rid"))
+ try:
+ randonb.pop(0)
+ print "POPPED"
+ except:
+ raise
+ print "Voici les numéros de randos:"
+ print randonb
+ except:
+ raise
+
+
+
+ try:
+ for i in randonb:
+ if maptype==1:
+ try:
+ print clc.okgreen+"Maybe downloading "+baseurl+i+'/trace/gpx'
+ dwnld = c.get(baseurl+i+'/trace/gpx')
+ except TypeError:
+ pass
+ except:
+ raise
+ filei(dwnld,folderpath+bfn)
+ elif maptype==2:
+ try:
+ print clc.okgreen+"Maybe downloading "+baseurl+i+'/trace/trk'
+ dwnld = c.get(baseurl+i+'/trace/trk')
+ except TypeError:
+ pass
+ except:
+ raise
+ filei(dwnld,folderpath+bfn)
+ else:
+ try:
+ print clc.okgreen+"Maybe downloading "+baseurl+i+'/trace/kml'
+ dwnld = c.get(baseurl+i+'/trace/kml')
+ except TypeError:
+ pass
+ except:
+ raise
+ filei(dwnld,folderpath+bfn)
+ except:
+ raise
+ try:
+ mpp.mapparsing(maptype,folderpath+bfn)
+ except:
+ raise
+ print("Finished writing file.")
+ except :
+ raise
+
+
diff --git a/randopitons.7 b/randopitons.7
deleted file mode 100644
index f4c082b..0000000
--- a/randopitons.7
+++ /dev/null
@@ -1,54 +0,0 @@
-.TH randopitons "05 Nov. 2018" "ver 0.1"
-
-.SH NAME
-randopitons.sh - A script for downloading hitchiking files from https://randopitons.re.
-
-.SH SYNOPSIS
-
-.B randopitons.sh
-[
-.B -lm / --list-maptype
-]
-[
-.B -lr / --list-regions
-]
-
-.B randopitons.sh
-[
-.B -u / --username
-"youremail@forrandopitons.re" ]
-
-.B randopitons.sh
-[
-.B -u / --username
-"youremail@forrandopitons.re" ]
-[
-.B -r / --region
- "a region"]
-
-.B randopitons.sh
-[
-.B -u / --username
-"youremail@forrandopitons.re" ]
-[
-.B -a / --all
-]
-[
-.B -em / --elevator-music
-]
-
-
-.SH SYNOPSIS
-.B randopitons.sh
-[
-.B -u / --username
-"youremail@forrandopitons.re" ]
-
-.SH DESCRIPTION
-You will need to make an account on the website before using the script.
-The following regions are valid: cilaos, salazie, mafate, est, nord, ouest, sud, volcan, ailleurs. Case insensitive.
-The elevator music need mpv and youtube-dl to be installed.
-
-.SH AUTHORS
-Lionel Miquel
-.B <lionel.miquel46@gmail.com>.
diff --git a/randopitons.7.gz b/randopitons.7.gz
index 7b6feff..7b6feff 100644..100755
--- a/randopitons.7.gz
+++ b/randopitons.7.gz
Binary files differ
diff --git a/randopitons.sh b/randopitons.sh
index 785f475..398b9f1 100644..100755
--- a/randopitons.sh
+++ b/randopitons.sh
@@ -38,7 +38,7 @@ _download()
_help()
{
- man ${__dir}/randopitons.1
+ man ${__dir}/randopitons.7.gz
exit
}
diff --git a/regions.txt b/regions.txt
new file mode 100755
index 0000000..9569285
--- /dev/null
+++ b/regions.txt
@@ -0,0 +1,10 @@
+Cirque de Cilaos
+Cirque de Mafate
+Cirque de Salazie
+Est
+Nord
+Ouest
+Sud
+Volcan
+Ailleurs
+All
diff --git a/webregions.txt b/webregions.txt
new file mode 100755
index 0000000..2479442
--- /dev/null
+++ b/webregions.txt
@@ -0,0 +1,9 @@
+cirque-cilaos
+cirque-mafate
+cirque-salazie
+est
+nord
+ouest
+sud
+volcan
+ailleurs