-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.py
More file actions
executable file
·101 lines (77 loc) · 2.5 KB
/
init.py
File metadata and controls
executable file
·101 lines (77 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
datasets = ['emplacement-des-gares-idf.csv',
'validations-sur-le-reseau-ferre-nombre-de-validations-par-jour-1er-sem.csv',
'validations-sur-le-reseau-ferre-profils-horaires-par-jour-type-1er-sem.csv']
import urllib.request
import os
#import pip._internal
#from pip import main
import importlib
import subprocess
import requests
url = "https://perso.esiee.fr/~barbosav/DRIO-4103C/DATA"
for file in datasets :
dir = './data/external/'
dirfile = dir + file
if os.path.isfile(dirfile) == False :
link = url + "/" + file
response = requests.get(link)
with open(os.path.join(dir, file), 'wb') as f:
f.write(response.content)
print("All files downloaded.")
packages = ["dash",
"dash.dependencies",
"dash_core_components",
"dash_html_components",
"plotly.plotly",
"plotly.graph_objs",
"json",
"pandas",
"numpy",
"time",
"math",
"ast"]
# def install_and_import2(package):
# try:
# importlib.import_module(package)
# except ImportError:
# import pip
# pip.main(['install', package])
# # finally:
# # globals()[package] = importlib.import_module(package)
def install_and_import2(package):
try:
importlib.import_module(package)
except ImportError:
#From pip._internal import main
from pip import main as pip
pip(['install', '--user', package])
importlib.import_module(package)
def install_and_import(package):
str = "pip install "+ package
subprocess.call(str, shell=True)
for pkg in packages :
install_and_import2(pkg)
print("All packages installed.")
# for file in datasets :
# dir = './data/external/'
# file = dir + file
# if os.path.isfile(file) == False :
# link = url + "/" + file
# urllib.request.urlretrieve(url, file)
# def install(package):
# # if hasattr(pip, 'main'):
# pip.main(['install', package])
# # else:
# # pip._internal.main(['install', package])
# import dash
# from dash.dependencies import Input, Output
# import dash_core_components as dcc
# import dash_html_components as html
# import plotly.plotly as py
# import plotly.graph_objs as go
# import json
# import pandas as pd
# import numpy as np
# import time
# import math
# import ast