2024-07-24 19:13:42 +02:00
import os
2024-10-25 23:19:29 +02:00
import argparse
2024-07-24 19:13:42 +02:00
2024-10-25 23:19:29 +02:00
input_file = " input_file "
2024-07-24 19:13:42 +02:00
2024-10-25 23:19:29 +02:00
def parse_args ( argv = None ) :
2024-07-24 19:13:42 +02:00
parser = argparse . ArgumentParser ( )
2024-10-25 23:19:29 +02:00
parser . add_argument (
" --dev_token " ,
type = str ,
default = os . environ [ " MAPILLARY_DEV_TOKEN " ] ,
help = " Your mapillary access token " ,
)
parser . add_argument (
" --username " ,
type = str ,
required = True ,
help = " Username to get the sequences id of " ,
)
2024-07-24 19:13:42 +02:00
global args
args = parser . parse_args ( argv )
2024-10-25 23:19:29 +02:00
if __name__ == " __main__ " :
print (
" Construction du script bash de récupération des images de chaque séquences pour Mapillary_download (https://github.com/Stefal/mapillary_download.git) "
)
2024-07-24 19:13:42 +02:00
parse_args ( )
2024-10-25 23:19:29 +02:00
username = args . username
2024-07-24 19:13:42 +02:00
input_file = f " sequences_ { username } .txt "
if not os . path . exists ( input_file ) or not os . path . isfile ( input_file ) :
2024-10-25 23:19:29 +02:00
print (
f " Erreur : Le fichier ' { input_file } ' n ' a pas été trouvé. Arrêt du script. "
)
2024-07-24 19:13:42 +02:00
exit ( 1 )
else :
print ( f " Fichier ' { input_file } ' trouvé. " )
output_file = f " script_bash_get_sequences_for_user_ { username } .sh "
2024-10-25 23:19:29 +02:00
access_token = " $MAPILLARY_DEV_TOKEN " # or, if you want to use the password in clear text: "'"+args.dev_token+"' "
2024-07-24 19:13:42 +02:00
with open ( output_file , " w " ) as output :
with open ( input_file , " r " ) as input_handle :
content = input_handle . read ( )
sequences = eval ( content )
for seq in sequences :
2024-10-25 23:19:29 +02:00
full_cmd = f " python mapillary_download.py { access_token } --sequence_ids= { seq } \n "
2024-07-24 19:13:42 +02:00
output . write ( full_cmd )
print ( output_file )
print ( f " \n Script Bash généré avec succès. " )
2024-10-25 23:19:29 +02:00
print (
f " Lancez le pour récupérer les photos de l ' utilisateur { username } : \n bash { output_file } "
)