示例#1
0
def main(argv):
    getDeleted = False

    opts, args = getopt.getopt(argv, "d", ["deleted"])

    for opt, arg in opts:
        if opt in ("-d", "--deleted"):
            getDeleted = True

            # create schema if db not exists
    if not os.path.isfile(config.database):
        createSchema = True
    else:
        createSchema = False

    connection = Connection(config.apikey)

    # connect to database
    db = sqlite3.connect(config.database)
    cursor = db.cursor()

    if createSchema:
        # open schema definition file
        file = open("schema.sql", "r")
        for line in file.readlines():
            cursor.execute(line)
        db.commit()

        # get projects
    project_ids = connection.project_ids()

    for project_id in project_ids:
        project = connection[project_id]

        cursor.execute(
            """SELECT *
			FROM shub_projects
			WHERE shub_id = ?""",
            (project.id,),
        )

        # insert if not exist
        if len(cursor.fetchall()) == 0:
            print "Guardando proyecto " + str(project.id) + "..."
            db.execute(
                """INSERT INTO shub_projects (shub_id)
							VALUES (?)""",
                [project.id],
            )

            # get finished jobs
        getJobs(db, project.jobs(state="finished"))

        # get deleted jobs
        if getDeleted:
            getJobs(db, project.jobs(state="deleted"))

    db.close()
示例#2
0
def _has_project_access(project, endpoint, apikey):
    conn = Connection(apikey, url=endpoint)
    try:
        return project in conn.project_ids()
    except APIError as e:
        if 'Authentication failed' in e.message:
            raise InvalidAuthException
        else:
            raise RemoteErrorException(e.message)
示例#3
0
文件: deploy.py 项目: pawelmhm/shub
def _has_project_access(project, endpoint, apikey):
    conn = Connection(apikey, url=endpoint)
    try:
        return project in conn.project_ids()
    except APIError as e:
        if "Authentication failed" in e.message:
            raise InvalidAuthException
        else:
            raise RemoteErrorException(e.message)
示例#4
0
文件: utils.py 项目: rowhit/shub
def has_project_access(project, endpoint, apikey):
    """Check whether an API key has access to a given project. May raise
    InvalidAuthException if the API key is invalid (but not if it is valid but
    lacks access to the project)"""
    conn = Connection(apikey, url=endpoint)
    try:
        return project in conn.project_ids()
    except APIError as e:
        if 'Authentication failed' in str(e):
            raise InvalidAuthException
        else:
            raise RemoteErrorException(str(e))
示例#5
0
# !/usr/bin/python
# -*- coding: utf-8 -*-
import MySQLdb
import sys
from geopy.exc import GeocoderTimedOut
sys.path.insert(0, 'C:\Users\home\greekbeachesapp')
from sunthesis import elegxos_paralias
from scrapinghub import Connection
from geopy.geocoders import Nominatim
import time
conn = Connection('57c54e0d05fb44439a9fc0887fb6ab3e')
print conn
print conn.project_ids()
project = conn[77608]
jobs = project.jobs(state='finished')
jobs_id = [x.id for x in jobs]
print jobs_id
job = project.job(u'77608/1/1')
source = 'e-zakynthos.com'
servername = "localhost"
username = "******"
password = ""
dbname = "database"
db = MySQLdb.connect(servername,
                     username,
                     password,
                     dbname,
                     charset="utf8",
                     use_unicode=True)
cursor = db.cursor()
z = u'\u0396\u03ac\u03ba\u03c5\u03bd\u03b8\u03bf\u03c2'