Example #1
0
def x_ping_all(console=True):
    '''
        Example - Have all the relays send a ping
    '''
    # Create and propagate a cortex of relays
    core = propagate(console)

    # Inject ping packets for each of the relays
    for relay in core.relays:
        # Create a spark
        spark = Spark(origin=core.relays[relay].name,
                      destination=None,
                      mode='ping')
        spark.encode_spark()
        this_spark = spark.get_spark()
        core.inject(this_spark)

    # Process the packets
    core.route_buffer()

    # Show the results
    core.show_local()
    core.show_relay_stats()
    core.compare_mappings()

    return core.get_logs()
Example #2
0
 def get(self):
     response = "Error"
     try:
         if self.get_argument("code", None):
             code = self.get_argument("code")
             access_token, refresh_token = yield self.get_tokens(code)
             person = yield Spark(access_token).get(
                 "https://webexapis.com/v1/people/me")
             print("OauthHandler.get person:{0}".format(person.body))
             person_id = person.body.get("id")
             self.application.settings['token_helper'].update_user(
                 person_id, access_token, refresh_token)
             response = "Access Granted"
         else:
             redirect_uri = 'https://webexapis.com/v1/authorize?client_id={0}&response_type=code&redirect_uri={1}&scope={2}'
             redirect_uri = redirect_uri.format(
                 Settings.client_id,
                 urllib.parse.quote_plus(Settings.redirect_uri),
                 Settings.scopes)
             print("OauthHandler.get redirect_uri:{0}".format(redirect_uri))
             self.redirect(redirect_uri)
             return
     except Exception as e:
         response = "{0}".format(e)
         print("OauthHandler.get Exception:{0}".format(e))
         traceback.print_exc()
     self.write(response)
Example #3
0
def x_ping_one(console=True):
    '''
        Example - Automatic ping injection
    '''
    # Create and propagate cortex of relays
    core = propagate(console)

    spark = Spark(origin=4, destination=None, mode='ping')
    spark.encode_spark()
    this_spark = spark.get_spark()
    core.inject(this_spark)

    # Process the packets
    core.route_buffer()

    # Show the resulks
    core.show_local()
    core.show_relay_stats()
    core.compare_mapping()
Example #4
0
def x_inject_ping(console=True):
    '''
        Example - Manual ping injection
    '''
    # Create and propagate cortex of relays
    core = propagate(console)

    # Create a spark
    spark = Spark(origin=1, destination=None, mode='ping')
    spark.encode_spark()
    this_spark = spark.get_spark()

    print(this_spark)
    print("\n")

    # Inject spark in to the cortex
    core.inject(this_spark)
    core.route_buffer()

    core.show_local()
    core.show_relay_stats()
Example #5
0
 def factory(workload_manager):
     if workload_manager == "SLURM":
         from slurm import Slurm
         return Slurm()
     elif workload_manager == "TORQUE":
         from torque import Torque
         return Torque()
     elif workload_manager == "BASH":
         from bash import Bash
         return Bash()
     elif workload_manager == "SPARK":
         from spark import Spark
         return Spark()
     else:
         return None
Example #6
0
from spark import Spark

bearerToken = "an example"
room = Spark.using(bearerToken).rooms().get()[0]
message = "Hello world!"

sent = Spark.using(bearerToken).room(room).message(message).post()
print("Message" + (" not" if not sent else "") + " posted to room")
from spark import Spark

bearerToken = "an example"
rooms = Spark.using(bearerToken).rooms().get()

print("Room titles are:")
for room in rooms:
    print(room.title)
from spark import Spark

bearerToken = "an example"
newRoom = Spark.using(bearerToken).room().create("Example")
print("Room" + (" not" if not newRoom else "") + " created")
# -*- coding: utf-8 -*-

import logging
from spark import Spark

spark = Spark.get_instance()


def load_data_from_csv(file_path, delimiter, header):
    logging.info('Importando arquivo {} para o Spark'.format(file_path))

    df = spark.read.option('delimiter', delimiter) \
                   .option('encoding', 'UTF-8') \
                   .csv(file_path, header=header)

    return df


def load_data_from_hive(table):
    logging.info('Importando tabela {} para o Spark'.format(table))

    df = spark.sql('SELECT * FROM {}'.format(table))

    return df
Example #10
0
logging.basicConfig(
    level=logging.DEBUG,
    format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
    datefmt="%d-%b-%y %H:%M:%S",
    handlers=[
        RotatingFileHandler(
            "Spark-Gram.log",
            maxBytes=Config.LOG_MAX_FILE_SIZE,
            backupCount=10
        ),
        logging.StreamHandler()
    ]
)
logging.getLogger("telethon").setLevel(logging.WARNING)
LOGGER = logging.getLogger(__name__)

if Config.USER_SESSION_STRING is not None:
    # for Running on Heroku
    session_string = str(Config.USER_SESSION_STRING)
    session = StringSession(session_string)
    spark = Spark(
        session,
        config=Config,
        logger=LOGGER
    )
    spark.run_until_disconnected()
else:
    LOGGER.error("USER_SESSION_STRING is mandatory to start session"
                 "\n please Enter USER_SESSION_STRING and restart")
Example #11
0
def x_create_spark():
    '''
        Example - Create a ping spark from relay 1
    '''
    spark = Spark(origin=1, destination=None, mode='ping')

    # Add two actions to the message
    spark.add_action("RUN")
    spark.add_action("RESTART")

    # Show the spark
    spark.show_spark()

    # Encode the spark and show the result
    spark.encode_spark()
    this_spark = spark.get_spark()
    print(this_spark)
Example #12
0
def x_complex(console=True):
    '''
        Example - complex
    '''
    # Create and propagate a cortex of relays
    core = propagate(console)

    # Inject ting packet
    spark = Spark(origin=1, destination=None, mode='ting')
    spark.encode_spark()
    this_spark = spark.get_spark()
    core.inject(this_spark)

    # Inject a ping packet
    spark = Spark(origin=12, destination=None, mode='ping')
    spark.encode_spark()
    this_spark = spark.get_spark()
    core.inject(this_spark)

    # Create an explorer spark
    spark = Spark(origin=1, destination=None, mode='explorer')
    spark.encode_spark()
    this_spark = spark.get_spark()

    core.inject(this_spark)

    core.route_buffer()

    core.show_relay_stats()
    core.compare_mappings()
 def setUpClass(cls):
     cls.spark = Spark(base_url='http://privateagent:1234/user/fulano')
Example #14
0
import network
from temperature import DS18B20x
from kalman import KalmanFilter
from spark import Spark

ESSID = "Incubator-1"

#peltier_fast    = DS18B20x(14, )
peltier_exact = DS18B20x(2, b'(D\x12-\t\x00\x00+')
#incubator_fast  = DS18B20x(16, 11)
#incubator_exact = DS18B20x(17, 12)

peltier_model = KalmanFilter(28, 400)
incubator_model = KalmanFilter(28, 400)

spark_controller = Spark(2)

fast_timer = machine.Timer(0)
exact_timer = machine.Timer(1)
kalman_timer = machine.Timer(2)


def disable_debug():
    esp.osdebug(None)


def fast_timer_IRQ(timer):
    pass


def exact_timer_IRQ(timer):
Example #15
0
                            msg = "Good job!"
                        else:
                            msg = "Wrong answer. The correct answer is: {0}".format(
                                correct_answer)
                    else:

                        msg = "Wrong input"

            if msg != None:
                spar.post('https://api.ciscospark.com/v1/messages', {
                    'markdown': msg,
                    'roomId': webhook['data']['roomId']
                })
        return "true"

    except urllib2.HTTPError as e:
        print("Error_Code: ", e.code, "Reason: ", e.reason)
        msg = "Oops, something went wrong with the server. Please try again"
        spar.post('https://api.ciscospark.com/v1/messages', {
            'markdown': msg,
            'roomId': webhook['data']['roomId']
        })


if __name__ == "__main__":
    bot_email = "BOT_EMAIL"
    bot_name = "BOT_NAME"
    spar = Spark(Settings.token)
    game = QuizFacts()
    run_itty(server='wsgiref', host='0.0.0.0', port=10070)