def delete_redshift_cluster():
    """
    This function deletes a cluster
    :return:
    """
    print("1.1 Client is created ...")
    redshift = boto3.client('redshift',
                            region_name="us-west-2",
                            aws_access_key_id=KEY,
                            aws_secret_access_key=SECRET)
    print("1.2 Cluster is identified ...")
    try:
        redshift.delete_cluster(ClusterIdentifier=DWH_CLUSTER_IDENTIFIER,
                                SkipFinalClusterSnapshot=True)
    except ClientError as e:
        print(f'ERROR: {e}')

    try:
        print("1.3 Cluster is being deleted ...")
        while redshift.describe_clusters(
                ClusterIdentifier=DWH_CLUSTER_IDENTIFIER)\
                ['Clusters'][0]['ClusterStatus'] == 'deleting':
            utils.animate()
    except:
        print("\r1.4 Cluster is deleted successfully ...")
    return None
Example #2
0
 def call(self):
     unread_text = Popen(["newsbeuter", "-x", "print-unread"], stdout=PIPE).communicate()[0]
     if unread_text.startswith("Error:"): return
     unread_items = int(unread_text.split()[0])
     if unread_items > 0:
         yield animate(10, "Newsbeuter: %d unread news." % (unread_items,))
     else:
         yield animate(10, "Newsbeuter: No unread news.")
Example #3
0
def mpd_np():
    """Display the mpd status via mpc."""
    try:
        status_output = Popen(["mpc", "status"], stdout=PIPE).communicate()[0]
    except OSError:
        yield wait(5, "mpc not installed :(")
        return

    result = ""

    lines = status_output.split("\n")
    if len(lines) < 3: # stopped
        yield wait(10, "MPD stopped")
    else:
        result += "MPD " + lines[1].split()[0] + " " + lines[0].strip()
        yield animate(10, result)
        yield animate(10, lines[1].split()[2])
Example #4
0
def memory_free():
    """Display the used RAM and Swap space."""
    yield animate(2, "Used RAM")
    
    # Parse the output of the "free" command. :(
    free_output = Popen(["free"], stdout=PIPE).communicate()[0]
    # get the interesting lines
    interesting = free_output.split("\n")[1:]
    total_ram = float(interesting[0].split()[1])
    used_ram = int(interesting[1].split()[2]) / total_ram
    total_swap = float(interesting[2].split()[1])
    used_swap = int(interesting[2].split()[2]) / total_swap

    yield animate(10, utils.pretty_progressbar(used_ram, 80))
    
    yield animate(2, "Used Swap Space")
    yield animate(10, utils.pretty_progressbar(used_swap, 80))
Example #5
0
def battery():
    """Display the battery status via acpi."""
    try:
        status_output = Popen(["acpi"], stdout=PIPE).communicate()[0]
    except OSError:
        yield wait(5, "battery status could not be determined.")
        return
    
    yield animate(10, status_output.split("\n")[0])
def create_redshift_cluster(roleArn):
    """
    This function creates a cluster on your behalf
    :param roleArn:
    :return:
    """
    print("1.1 Client is created ...")
    redshift = boto3.client('redshift',
                            region_name="us-west-2",
                            aws_access_key_id=KEY,
                            aws_secret_access_key=SECRET)
    try:
        print("1.2 Cluster config is being created ...")
        redshift.create_cluster(
            # HW
            ClusterType=DWH_CLUSTER_TYPE,
            NodeType=DWH_NODE_TYPE,
            NumberOfNodes=int(DWH_NUM_NODES),

            # Identifiers & Credentials
            DBName=DWH_DB,
            ClusterIdentifier=DWH_CLUSTER_IDENTIFIER,
            MasterUsername=DWH_DB_USER,
            MasterUserPassword=DWH_DB_PASSWORD,

            # Roles (for s3 access)
            IamRoles=[roleArn])
    except ClientError as e:
        print(f'ERROR: {e}')

    print("1.3 Cluster is being created ...")
    while redshift.describe_clusters(
            ClusterIdentifier=DWH_CLUSTER_IDENTIFIER)\
            ['Clusters'][0]['ClusterStatus'] != 'available':
        utils.animate()

    print("\r1.4 Cluster is created successfully ...")
    return redshift.describe_clusters(
        ClusterIdentifier=DWH_CLUSTER_IDENTIFIER)\
    ['Clusters'][0]['Endpoint']['Address']
Example #7
0
    def save_plots(self, data_dict, ep):
        animate(self.matrix3d, data_dict['valve.npy'],
                self.dir + 'valve' + str(ep) + '.mp4')
        animate(self.matrix3d, data_dict['myocardium.npy'],
                self.dir + 'myocardium' + str(ep) + '.mp4')
        animate(self.matrix3d, data_dict['s.npy'],
                self.dir + 's' + str(ep) + '.mp4')

        fig, ax = plt.subplots(figsize=(8, 8), nrows=2, ncols=2)
        U = data_dict['U'].reshape((self.vert, self.horz, self.d))
        ax[0, 0].imshow(U[:, :, 0], cmap='binary')
        ax[0, 1].imshow(U[:, :, 1], cmap='binary')
        plt.savefig(self.dir + 'U' + str(ep) + '.jpg')

        plt.plot(data_dict['V'])
        plt.savefig(self.dir + 'V' + str(ep) + '.jpg')
Example #8
0
	def env_plot(self):
		plot_time_series(self.sim_obj.grid)
		animate(self.sim_obj.grid,True,self.color_list,0.5)
Example #9
0
def startup_animation():
    """Animate the startup of the script."""
    yield wait(1, "DWM Status Bar Animator")
    yield animate(1, "a silly script by timonator")
Example #10
0
    time.sleep(ticks)
except KeyboardInterrupt:
    pass

# kill seller thread
seller_apple.kill()
seller_samsung.kill()

Save(seller_apple, object_type='seller')
Save(seller_samsung, object_type='seller')
# Plot the sales and expenditure trends
plot(seller_apple)
plot(seller_samsung)

regression(seller_apple)
regression(seller_samsung)

for product in seller_apple.product_list:
    print('Total Profit Apple ' + product.name + ': ', seller_apple.my_profit(product))
for product in seller_samsung.product_list:
    print('Total Profit Samsung ' + product.name + ': ', seller_samsung.my_profit(product))

# Kill consumer threads
for consumer in customers:
    consumer.kill()

dataCenter.kill()
utils.animate(dataCenter)
# from market import Market
# correlation_map = Market.correlation_map
Example #11
0
INFO = {  # parameters for the animation
    "quarto_stato": {
        "fps": 10
    },
    "arduino": {
        "fps": 20
    }
}

if __name__ == "__main__":
    out_mode = get_out_mode()

    for name in INFO.keys():
        print("\n" + name + ".png")
        target = mpimg.imread("images/" + name + "/target.png")
        model = mpimg.imread("images/" + name + "/model.png")

        swarm = Swarm([(0, target.shape[1] - model.shape[1]), (0, target.shape[0] - model.shape[0])],
                      lambda x, y: dissimilarity(x, y, model, target), 0.5)

        if out_mode == ANIMATION:
            display(model, target, name)
            fig, title, boxes = init(model, target, name)
            anim = animate(fig, update, lambda: gen_data(swarm), INFO[name]["fps"])
#            save(anim, name + "/" + name, INFO[name]["fps"], ".mp4")
        elif out_mode == TEXT:
            swarm.minimize()

    print()