Example #1
0
 def dehydrate(self, bundle):
     bundle.data['place_id'] = bundle.obj.university.city_id
     bundle.data['place_name'] = bundle.obj.university.city
     bundle.data['university_id'] = bundle.obj.university.id
     bundle.data['university_name'] = bundle.obj.university
     bundle.data['date'] = timestamp(bundle.obj.date)
     #        bundle.data['wtdate'] = bundle.obj.wtdate.strftime("%Y-%m-%d %H:%M:%S")
     bundle.data['wtdate'] = timestamp(bundle.obj.wtdate)
     bundle.data['location'] = bundle.obj.place
     bundle.data['url_picture'] = bundle.obj.cover
     return bundle
Example #2
0
def git_commit(message):
    """ perfrom git commit -m [message] """


    # check if git index is empty or not
    with open('.git/index', 'r') as f:
        data = f.read()
        if not len(data):
            # Output error message
            return
        f.close()
    
    time = timestamp(mili=True, str_type=False)
    LOGNAME = environ['LOGNAME']

    # update .git/commits directory
    with open('.git/commits' + '/' + str(time), 'w') as f:
        #.write(LOGNAME + '\n' + str(int(time)) + '\n' + '\n' + message + '\n')
        f.write('\n'.join([LOGNAME, str(int(time)), '', message]))
    # update .git/index
    update_git_index()

    # update snapshot
    update_snap_shot(str(time))

    current_head = content('.git/HEAD')
    with open('.git/refs/heads/' + current_head,'w') as f:
        f.write(str(time))
Example #3
0
def update_git_index(file):
    Git_Index = '.git/index'
    seek_pos = 0
    file_exist = False

    with open(Git_Index, 'r') as f:
        for line in f:
            if line.find(file) < 0:
                seek_pos += len(line)
            else:
                file_exist = True
                break

    with open(Git_Index, 'r+b') as f:
        f.seek(seek_pos)
        if not file_exist:
            f.write(
                make_string(str(timestamp()), sha1(file), sha1(file), ' ' * 40,
                            file))
        else:
            f.write(make_string(str(timestamp()), sha1(file), sha1(file)))
Example #4
0
def pushdata(type):
    # push individual bottles
    curTime = timestamp()
    rfid = str(random.randint(101, 106)) + '-' + str(random.randint(1, 200))
    bottletype = type
    machine = random.randint(1, 3)
    db.push({
        "machine": machine,
        "RFID": rfid,
        "time": curTime.replace('"', ''),
        "type": bottletype
    })
Example #5
0
def login():
    session.pop('logged_in', None)
    session.pop('last', None)
    session.pop('user',None)

    error = None
    if request.method == 'POST':
        con = mdb.connect(options['DB_HOST'], options['DB_USERNAME'], options['DB_PASSWORD'], options['DB']);
        cur = con.cursor()
        cur.execute('SELECT password FROM users where user= %s LIMIT 1',(request.form['username']))
        rows = cur.fetchall()
        if(len(rows)>0):
            if (request.form['password']==rows[0][0]):
                logging.info('Plaintext Password for %s OK encrypting password now.',request.form['username'])
                password=bcrypt.hashpw(request.form['password'],bcrypt.gensalt())
                cur.execute('UPDATE users set password = %s where user = %s;',(password,request.form['username']))
                con.commit()
                rows = cur.fetchall()
                session['logged_in'] = True
                session['last']=timestamp()
                session['user']=request.form['username']
                flash('You were logged in')
                con.close()
                return redirect(url_for('index'))
            elif(bcrypt.hashpw(request.form['password'], rows[0][0]) == rows[0][0]):
                logging.info('BCrypt Password for %s OK',request.form['username'])
                session['logged_in'] = True
                session['last']=timestamp()
                session['user']=request.form['username']
                flash('You were logged in')
                con.close()
                return redirect(url_for('index'))
            else:
                logging.info('Login error')
                session.pop('logged_in', None)
                session.pop('last',None)
                session.pop('user',None)

    return render_template('login.html', error=error)
Example #6
0
def func_1(entry, entry_3, label_23, label_15, label_16, label_17, label_18):
    ticker = entry
    date = entry_3
    company_name_1, ticker, company_name = symbol(ticker)
    label_23['text'] = company_name
    o, h, l, c = timestamp(ticker, date)
    label_15['text'] = o
    label_16['text'] = h
    label_17['text'] = l
    label_18['text'] = c
    global name_1
    global image
    name_1 = logo(company_name_1, ticker)
    image = PhotoImage(file=name_1)
    label_26 = Label(frame, image=image)
    label_26.place(x=720, y=90)
Example #7
0
def init_report(self):
    self.log_directory = './HistoryLogs/'
    time_filename = timestamp('_')
    self.meas_filename = self.log_directory+time_filename+'upsmeas.txt'

    meas_header = []
    meas_header.append('UPS meas starts @:'+str(datetime.datetime.now()))
    meas_header.append("Measure#")
    meas_header.append("BatteryVoltage")
    meas_header.append("BatteryEstimatedMinutesRemaining")
    meas_header.append("getUpsAlarmGroupA")
    meas_header.append("getUpsBatteryStatus")

    self.meas_file = open(self.meas_filename,'a')
    self.meas_file.write(meas_header)

    self.meas_file.close()
Example #8
0
def on_create():
    provider = [ {  "providerId" : request.get_json()['providerId'],
                    "data" : [
                                {  "name":  request.get_json()['name'],
                                    "age" :  request.get_json()['age'],
                                    "timestamp" : timestamp()
                                    }
                            ] 
                }]
    if type(provider[0]["data"][0]["name"]) != str or type(provider[0]["data"][0]['age']) != int:
        return jsonify({ "status": 300,
                         "message": "Enter a valid data type"}),300
    Providers.append(provider)
    return jsonify({ "status": 201,
                     "message": "added successful",
                     "data":Providers
                     }), 201
Example #9
0
def create_primitive_token(value, multiline_strings_allowed=True):
    """
    Creates and returns a single token for the given primitive atomic value.

    Raises NotPrimitiveError when the given value is not a primitive atomic value
    """
    if value is None:
        return create_primitive_token('')
    elif isinstance(value, bool):
        return tokens.Token(tokens.TYPE_BOOLEAN, u'true' if value else u'false')
    elif isinstance(value, int):
        return tokens.Token(tokens.TYPE_INTEGER, u'{}'.format(value))
    elif isinstance(value, float):
        return tokens.Token(tokens.TYPE_FLOAT, u'{}'.format(value))
    elif isinstance(value, (datetime.datetime, datetime.date, datetime.time)):
        ts = timestamp(value) // 1000
        return tokens.Token(tokens.TYPE_DATE, strict_rfc3339.timestamp_to_rfc3339_utcoffset(ts))
    elif isinstance(value, six.string_types):
        return create_string_token(value, multiline_strings_allowed=multiline_strings_allowed)

    raise NotPrimitiveError("{} of type {}".format(value, type(value)))
Example #10
0
def create_primitive_token(value, multiline_strings_allowed=True):
    """
    Creates and returns a single token for the given primitive atomic value.

    Raises NotPrimitiveError when the given value is not a primitive atomic value
    """
    if value is None:
        return create_primitive_token('')
    elif isinstance(value, bool):
        return tokens.Token(tokens.TYPE_BOOLEAN,
                            u'true' if value else u'false')
    elif isinstance(value, int):
        return tokens.Token(tokens.TYPE_INTEGER, u'{}'.format(value))
    elif isinstance(value, float):
        return tokens.Token(tokens.TYPE_FLOAT, u'{}'.format(value))
    elif isinstance(value, (datetime.datetime, datetime.date, datetime.time)):
        ts = timestamp(value) // 1000
        return tokens.Token(tokens.TYPE_DATE,
                            strict_rfc3339.timestamp_to_rfc3339_utcoffset(ts))
    elif isinstance(value, six.string_types):
        return create_string_token(
            value, multiline_strings_allowed=multiline_strings_allowed)

    raise NotPrimitiveError("{} of type {}".format(value, type(value)))
Example #11
0
from queue import Queue
import timestamp as timestamp
from spider import Spider
from Domain import *
from DataFiles import *

# x = "http://www.wikipedia.org"
# x = "http://www.wallpaperscraft.com"
x = "https://unsplash.com/search/photos/wallpaper"
# x = "https://unsplash.com/search/photos/wallpaper"
# x = "https://www.facebook.com"
# x = "https://wallpaperscraft.com/wallpaper/bubbles_circles_dark_136091"
# x = "https://wallpapers.wallhaven.cc"
# x = "https://www.google.com/search?tbm=isch&q=tigger"

PROJECT_NAME = str(timestamp())
print(PROJECT_NAME)
HOMEPAGE = x
DOMAIN_NAME = get_domain_name(HOMEPAGE)
QUEUE_FILE = PROJECT_NAME + '/queue.txt'
CRAWLED_FILE = PROJECT_NAME + '/crawled.txt'
NUMBER_OF_THREADS = 8
queue = Queue()
Spider(PROJECT_NAME, HOMEPAGE, DOMAIN_NAME)


def crawl():
    queued_links = file_to_set(QUEUE_FILE)
    if len(queued_links) > 0:
        print(str(len(queued_links)) + ' Links in the queue')
        create_jobs()
Example #12
0
 def decorated(*args, **kwargs):
     if not session.get('logged_in') or ((timestamp()-session['last']) > options['SESSION_EXPIRE']):
         return redirect(url_for('login'))
     session['last']=timestamp()
     return f(*args, **kwargs)
Example #13
0
	def testIt(self):
		_timestamp = time.time()
		self.assertEqual(timestamp(datetime.fromtimestamp(_timestamp)), int(_timestamp)*1000)
Example #14
0
import os
import csv
from datetime import datetime
from scipy.io.wavfile import read
from scipy.signal import stft
from scipy.signal.windows import hamming
from scipy.signal import find_peaks

# Import the data
#Import the audio file from Public
for root, dirs, files in os.walk(r'P:\+Courses\AstroStats\LivingSeaSculpture\Initial Data for Testing'): #Iterate through files in our testing folder
    for name in files:
        # print(os.path.abspath(os.path.join(root, name)))
<<<<<<< HEAD
        if name == "FFT_Test.wav": #If the file is the one we want:
>>>>>>> 8a62b64d993124bc68fc778083681f6faa351367
            [sample_rate, data] = read(os.path.abspath(os.path.join(root, name))) #Open the file into a 2D array

# Filter the data
boat = boatfilt(sample_rate,data)
[t, fish] = fishfilt(data,sample_rate)

# Timestamp the data
[shrimpstamps,fishstamps] = timestamp(t, fish)

# Make the CSV file
# In progress
makefile(boat[0],boat[1],fishstamps,shrimpstamps,'test_folder','testdata')

# Plot the output
makegraph(boat,shrimpstamps,fishstamps, len(data[:,0])/sample_rate,15)