This commit is contained in:
Francois 2019-03-05 00:47:57 +01:00
vanhempi f71fae4267
commit 14ad2c0492
25 muutettua tiedostoa jossa 80 lisäystä ja 0 poistoa

Näytä tiedosto

@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
class DataBaseManager:
def __init__(self, connexion, config):
self.conn = connexion
self.config = config
self.cursor = self.conn.cursor()
def createPicturesTable(self, force = False):
if force:
self.cursor.execute("DROP TABLE IF EXISTS `iss`.`pictures`;")
self.cursor.execute("""
CREATE TABLE `iss`.`pictures` (
`pictures_latitude` FLOAT(10, 6) NULL,
`pictures_longitude` FLOAT(10, 6 ) NULL ,
`pictures_id` VARCHAR( 15 ) PRIMARY KEY ,
`pictures_timestamp` TIMESTAMP NULL ,
`pictures_location` TEXT NULL
) ENGINE = MYISAM ;
""")
def insertRowPictures(self, array):
sql_insert_template = "INSERT INTO `iss`.`pictures` (pictures_latitude, pictures_longitude, pictures_id, pictures_timestamp, pictures_location) VALUES (%s, %s, %s, %s, %s);"
self.cursor.executemany(sql_insert_template, array)
self.conn.commit()
return self.cursor.rowcount
def select(self, array):
sql = """
SELECT tmp.* FROM (
SELECT
COUNT(*) as nb,
pictures_location as location
FROM iss.pictures
GROUP BY pictures_location
) as tmp
ORDER BY nb DESC
"""

Näytä tiedosto

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-

Näytä tiedosto

@ -0,0 +1,8 @@
#!/bin/sh
## synchroniser avec les images déjà collectées
rsync -rve ssh my-deblan:~/projets/ISS-HDEV-wallpaper/Collections/ ~/Projets/smart-iss-posts/data/raw/collections/
scp -v ssh my-deblan:~/projets/ISS-HDEV-wallpaper/history.txt ~/Projets/smart-iss-posts/data/raw/history/

22
iss/tools/config.py Normal file
Näytä tiedosto

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
import os
import sys
import yaml
from dotenv import find_dotenv, load_dotenv
load_dotenv(find_dotenv())
class Config:
def __init__(self, project_dir = os.getenv("PROJECT_DIR"), mode = os.getenv("MODE")):
self.project_dir = project_dir
self.mode = mode
with open(os.path.join(self.project_dir, 'config', 'config_%s.yaml' % (self.mode)), 'r') as ymlfile:
self.config = yaml.load(ymlfile)
def get(self, key):
return self.config[key]