Exemple #1
0
def checkForTweets(api, maxTime):
    messages = api.list_direct_messages(100)
    times = []
    print('Checking for new messages')
    newMessages = False
    for dm in messages:
        message_data = dm.message_create['message_data']
        text = message_data['text']
        senderID = dm.message_create['sender_id']
        sender = api.get_user(senderID).screen_name
        # new_since_id = max()
        times.append(dm.created_timestamp)
        recipient = api.get_user(
            dm.message_create['target']['recipient_id']).screen_name
        same = (recipient == sender)
        if int(dm.created_timestamp) > int(maxTime) and (sender !=
                                                         'APlayaNamedZach'):
            print('Responding to message from: ', sender)
            filename = parseTweets(api, sender)
            tweet = generateTweet(filename)
            api.send_direct_message(senderID, tweet)
            print('Sending tweet: ', tweet)
            newMessages = True
    if not newMessages:
        print('No new messages')
    maxTime = max(times)
    setConfig(maxTime)
    return maxTime
    def changeHostAndPort(self, host, port):
        config.setConfig('URL', 'host', host)
        config.setConfig('URL', 'port', port)
        self.currentHostSignal.emit()
        self.currentPortSignal.emit()
        self.mainWindow.listChannels.setChannel()
        try:
            self.mainWindow.listEpg.setEpg(address=self.mainWindow.listChannels
                                           ._channels[0]._channel_address)
            self.mainWindow.listEpg.updateEpg()
        except:
            self.mainWindow.listEpg.clearEpg()
        self.mainWindow.videoControls.stopped()
        utils.clearVideoFrame(self.mainWindow)
        self.mainWindow.child_position = None
        self.mainWindow.child_epg = None
        self.mainWindow.custom_epg = False
        self.mainWindow.media_state = False
        self.mainWindow.listSegmentPostiton.deleteAllSegment()
        self.mainWindow.current_epg_obj = None
        self.mainWindow.focusState.setMediaSetState(0)

        emptyEpgObj = models.EPG.create()
        emptyEpgQObj = EPG(emptyEpgObj)
        self.mainWindow.selectedEPG.setSelectedEPG(emptyEpgQObj)
Exemple #3
0
def checkForDMs(api, maxTime):
    messages = api.list_direct_messages(100)
    times = []
    messages_list = []
    print('Checking for new messages')
    newMessages = False
    for dm in messages:
        message_data = dm.message_create['message_data']
        text = message_data['text']
        senderID = dm.message_create['sender_id']
        sender = api.get_user(senderID).screen_name
        # new_since_id = max()
        latest_time = dm.created_timestamp
        times.append(latest_time)
        recipient = api.get_user(
            dm.message_create['target']['recipient_id']).screen_name
        same = (recipient == sender)
        if int(dm.created_timestamp) > int(maxTime) and (sender !=
                                                         'fake_laurarawra'):
            print('Responding to message from: ', sender)
            # names = [x for x in text.split(' ') if '@' in x]
            messages_list.append([senderID, text, sender])
            newMessages = True
    if not newMessages:
        print('No new messages')
        return [], maxTime
    maxTime = max(times)
    setConfig(maxTime)
    return messages_list, maxTime
Exemple #4
0
def setupConfig(proj_dir, base_dir):
    """
    Setup the :mod:`config` module using the config file that will be or is in
    the project directory.

    The project and base directories will only be stored if the config is new.

    :param proj_dir: The absolute path to the project directory.
    :type proj_dir: ``str``
    :param base_dir: The absolute path to the base (server installation) 
                     directory.
    :type base_dir: ``str``
    :returns: ``True`` if there was not an existing config file. (i.e. this was
              a new configuration.)
    :rtype: ``bool``

    """

    config_file = os.path.join(proj_dir, pb.appname_file+".config")
    print "Using " + config_file + " as the config file."
    config.setConfig(config_file)

    new_config = not config.onDisk()

    if new_config:
        print "Storing essential directories."
        config.getSettings("global")["basedir"] = base_dir
        config.getSettings("global")["projdir"] = proj_dir
    else:
        print "Config Loaded."

    return new_config
def config_p():
    configdata = json.loads(request.forms.get('configdata'))
    for cfg in configdata:
        if cfg[0] == "cfg_grab_time":
            if cfg[1] != config.cfg_grab_time:
                grabthread.run()
    config.setConfig(configdata)
    return
def config_p():
    configdata = json.loads(request.forms.get('configdata'))
    for cfg in configdata:
        if cfg[0]=="cfg_grab_time":
            if cfg[1]!=config.cfg_grab_time:
                grabthread.run()
    config.setConfig(configdata)
    return "null"
Exemple #7
0
def set_cartesian_constraints(x, constraints, solver):
    """For x a workspace parameter setting (achieved via config.getConfig(constraints)),
    a set of constraints, and a IKSolver object, modifies the constraints
    and the solver so that the solver is setup to match the workspace parameter
    setting x."""
    config.setConfig(constraints, x)
    solver.clear()
    for c in constraints:
        solver.add(c)
def config_p():
    attrl = []
    dicts = config.getDict()
    for d in dicts:
        val = request.forms.get(d)
        attrl.append([d, val])
    config.setConfig(attrl)
    grabthread.run()
    redirect("/config")
def config_p():
    attrl = []
    dicts = config.getDict()
    for d in dicts:
        val = request.forms.get(d)
        attrl.append([d, val])
    config.setConfig(attrl)
    grabthread.run()
    redirect("/config")
def set_cartesian_constraints(x,constraints,solver):
    """For x a workspace parameter setting (achieved via config.getConfig(constraints)),
    a set of constraints, and a IKSolver object, modifies the constraints
    and the solver so that the solver is setup to match the workspace parameter
    setting x."""
    config.setConfig(constraints,x)
    solver.clear()
    for c in constraints:
        solver.add(c)
Exemple #11
0
def set_cartesian_constraints(x, constraints, solver):
    """For `x` a workspace parameter setting (retrieved via
    `config.getConfig(constraints)`), a set of constraints, and a ``IKSolver``
    object `solver`, modifies the constraints and the solver so that the
    solver is setup to match the workspace parameter setting `x`.
    """
    config.setConfig(constraints, x)
    solver.clear()
    for c in constraints:
        solver.add(c)
 def store(self):
     save_path = config.getStorePath()
     if save_path is None:
         save_path = str(
             QFileDialog.getExistingDirectory(self.mainWindow, 'Save path'))
         config.setConfig('STORE', 'path', save_path)
         self.mainWindow.appSettings.currentStoreFolderSignal.emit()
     if len(save_path) is not 0:
         recorder = VlcRecorder(self.mainWindow, save_path)
         recorder.store(self.mainWindow.listSegmentPostiton.segment_list)
    def changeStorePath(self, path):
        holyPath = path[8:]
        config.setConfig('STORE', 'path', holyPath)
        self.currentStoreFolderSignal.emit()


# class ReaderLogs(threading.Thread):
#
#     def __init__(self, pathUrl, path_to_save):
#         super().__init__()
#         self.state = False
#         self.pathUrl = pathUrl
#         self.path_to_save = path_to_save
#
#     def run(self):
#         r = requests.get(self.pathUrl, stream=True)
#         if r.status_code == 200:
#             with open(self.path_to_save, "wb") as f:
#                 for chunk in r.iter_content(1024):
#                     f.write(chunk)
#         self.state = True
Exemple #14
0
def saveConfig():
    print(myconfig)
    config.setConfig(myconfig)
import os
import subprocess
from config import setConfig

#Configure with config.txt
configData = []
setConfig(configData)
blockSize = configData[0]
thisNode = configData[1]
otherNodes = configData
otherNodes.remove(blockSize)
otherNodes.remove(thisNode)
#Run server listening on 'thisNode' port
server = subprocess.Popen(["./server", thisNode])
#Create FAT if there isn't one
#if not os.path.exists("fat.txt") :
fatFile = open("fat.txt", "w")
fatFile.write("Filename\tBlock\tNode\n")
fatFile.close()
#Watch updates.txt
watcher = subprocess.Popen(["python", "updatewatcher.py"])
#Continuously ask for input
while 1:
    command = input("Enter command: \n\
    showfat\n\
    add <filename>\n\
    get <filename>\n\
    exit\n")
    #Print FAT
    if command == "showfat":
        fatFile = open("fat.txt", "r")
import os
from config import Config, setConfig, create_app
from waitress import serve

if __name__ == '__main__':
    is_prod = False
    config = Config()

    if os.environ.get('WORK_ENV') == 'PROD':
        config.debug = False
        is_prod = True
    else:
        config.debug = True

    setConfig(config)
    app = create_app(config)
    serve(app, port=8000, host="0.0.0.0")
Exemple #17
0
try:
    raw_input()
except KeyboardInterrupt:
    print "\nBye Bye..."
    sys.exit()

print "Oh good, let's continue then"

show_break()

# Load / Create config

config_file = os.path.join(proj_dir, pb.appname_file+".config")
print "Using " + config_file + " as the config file."

config.setConfig(config_file)

new_config = not config.onDisk()

config.getSettings("global")["basedir"] = base_dir

if new_config:
    config.getSettings("global")["projdir"] = proj_dir
else:
    print "Config Loaded"

show_break()

# Security Setup

# Has to be imported after config is set up
 def changeSavePath(self, path):
     holyPath = path[8:]
     config.setConfig('SAVE', 'path', holyPath)
     self.currentFolderSignal.emit()
Exemple #19
0
from mechanize import Browser
import config
import time
from BeautifulSoup import BeautifulSoup
from pygame import error as PygameError, mixer


class MusicFileError(Exception):
    pass


if config.isConfigFile():
    r = config.checkValido('Continuar con configuracion actual?')
    if r == 'n':
        config.setConfig()
else:
    config.setConfig()
params = config.readConfig()

USERNAME = params['USERNAME']
PASSWORD = params['PASSWORD']
CONTROL = params['CONTROL']  # EX = examen, C1 = control 1, etc...
PREGUNTAS = params['PREGUNTAS']
R1 = params['R2']
R2 = params['R1']
RAMOS = params['RAMOS']
MENSAJES_CADA = params[
    'MENSAJES_CADA']  # La cantidad de segundos entre mensaje y mensaje

# MUSICA: lista de una lista por ramo, cada lista contiene la musica que
# se va a reproducir dependiendo de si cagaste, vas a ex de 2da, pasaste, respectivamente
Exemple #20
0
def saveConfig():
    mqtt_log(myconfig)
    config.setConfig(myconfig)