S3Zilla: a file transfer program based on GUI / Tkinter encoded in Python

Here is the repository. Use the S3 API to transfer files. Multiple files can be selected for upload / download.

The Windows version is basically the same, except for some of the Tkinter widget sizes.

Enjoy!

#! /usr/bin/python3
from tkinter import *
from tkinter.filedialog import askdirectory
from os import listdir, remove, execl
from shutil import rmtree, make_archive
from getpass import getuser, getpass
from os.path import isdir, basename
from time import sleep
from sys import executable, argv
try:
    import boto3
    from botocore.exceptions import ClientError
except ImportError as e:
    print("Unable to import boto3n%s" % e)
    exit()


class S3Zilla:
    def __init__(self, master):
        error_msg = "Ensure S3 is configured on your machine:"
        try:
            self.s3 = boto3.resource('s3')
        except Exception as e:
            print("%s: %s" % (error_msg, e))
            exit(1)
        try:
            self.s3c = boto3.client('s3')
        except Exception as err:
            print("%s: %s" % (error_msg, err))
            exit(1)
        self.colors = {
            'light-grey': '#D9D9D9',
            'blue': '#2B547E',
            'black': '#000000',
            'red': '#FF3346',
            'grey': '#262626',
            'cyan': '#80DFFF'
        }
        self.master = master
        self.master.title("Amazon S3 File Transfer Client")
        self.master.configure(bg=self.colors('grey'))
        self.master.geometry("885x645")
        menu = Menu(self.master)
        menu.config(
            background=self.colors('grey'),
            fg=self.colors('light-grey')
        )
        self.master.config(menu=menu)
        file = Menu(menu)
        file.add_command(
            label="Exit",
            command=self.quit
        )
        menu.add_cascade(
            label="File",
            menu=file
        )
        refresh = Menu(menu)
        refresh.add_command(
            label="Local",
            command=self.refresh_local
        )
        refresh.add_command(
            label="S3",
            command=self.refresh_s3
        )
        menu.add_cascade(label="Refresh", menu=refresh)
        self.dir, self.drp_sel, self.bucket_name = '', '', ''
        self.folder_path = StringVar()
        self.dropdown = StringVar()
        self.dropdown_data = self.populate_dropdown()
        if not self.dropdown_data:
            self.dropdown_data = ('none available')
        self.deleted = False
        self.local_sel, self.s3_sel = (() for i in range(2))
        self.title_label = Label(
            master,
            fg=self.colors('light-grey'),
            bg=self.colors('grey'),
            font="Helvetica 10 bold",
            width=120
        )
        self.local_label = Label(
            master,
            fg=self.colors('light-grey'),
            bg=self.colors('grey'),
            text="LOCAL FILE SYSTEM",
            font="Helvetica 10 bold underline",
            width=60
        )
        self.s3_label = Label(
            master,
            fg=self.colors('light-grey'),
            bg=self.colors('grey'),
            text="AMAZON  S3",
            font="Helvetica 10 bold underline",
            underline=True,
            width=60
        )
        self.dropdown_box = OptionMenu(
            master,
            self.dropdown,
            *self.dropdown_data,
            command=self.set_drop_val
        )
        self.dropdown_box.configure(
            fg=self.colors('light-grey'),
            bg=self.colors('blue'),
            width=27,
            highlightbackground=self.colors('black'),
            highlightthickness=2
        )
        self.browse_button = Button(
            master,
            fg=self.colors('light-grey'),
            bg=self.colors('blue'),
            text="Browse",
            width=30,
            highlightbackground=self.colors('black'),
            highlightthickness=2,
            command=self.load_dir
        )
        self.browse_label = Label(
            master,
            fg=self.colors('light-grey'),
            bg=self.colors('grey'),
            text="No directory selected",
            width=37,
            font="Helvetica 10"
        )
        self.bucket_label = Label(
            master,
            fg=self.colors('light-grey'),
            bg=self.colors('grey'),
            text="No bucket selected",
            width=37,
            font="Helvetica 10"
        )
        self.refresh_btn_local = Button(
            master,
            fg=self.colors('light-grey'),
            bg=self.colors('blue'),
            text="REFRESH",
            width=30,
            highlightbackground=self.colors('black'),
            highlightthickness=2,
            command=self.refresh_local
        )
        self.refresh_btn_s3 = Button(
            master,
            fg=self.colors('light-grey'),
            bg=self.colors('blue'),
            text="REFRESH",
            width=30,
            highlightbackground=self.colors('black'),
            highlightthickness=2,
            command=self.refresh_s3
        )
        self.explorer_label_local = Label(
            master,
            fg=self.colors('light-grey'),
            bg=self.colors('blue'),
            width=30,
            text="Local File System:  "
        )
        self.explorer_label_s3 = Label(
            master,
            fg=self.colors('light-grey'),
            bg=self.colors('black'),
            width=30,
            text="S3 File System"
        )
        self.ex_loc = Listbox(
            master,
            fg=self.colors('cyan'),
            bg=self.colors('black'),
            width=49,
            height=18,
            highlightcolor=self.colors('black'),
            selectmode="multiple"
        )
        self.ex_s3 = Listbox(
            master,
            fg=self.colors('cyan'),
            bg=self.colors('black'),
            width=49,
            height=18,
            highlightcolor=self.colors('black'),
            selectmode="multiple"
        )
        self.upload_button = Button(
            master,
            fg=self.colors('light-grey'),
            bg=self.colors('blue'),
            text="Upload ->",
            width=20,
            highlightbackground=self.colors('black'),
            highlightthickness=2,
            command=self.upload
        )
        self.download_button = Button(
            master,
            fg=self.colors('light-grey'),
            bg=self.colors('blue'),
            text="<- Download",
            width=20,
            highlightbackground=self.colors('black'),
            highlightthickness=2,
            command=self.download
        )
        self.delete_local = Button(
            master,
            fg=self.colors('light-grey'),
            bg=self.colors('red'),
            text="DELETE",
            width=20,
            highlightbackground=self.colors('black'),
            command=self.delete_local_records
        )
        self.delete_s3 = Button(
            master,
            fg=self.colors('light-grey'),
            bg=self.colors('red'),
            text="DELETE",
            width=20,
            highlightbackground=self.colors('black'),
            command=self.delete_s3_records
        )
        self.found_label_local = Label(
            master,
            fg=self.colors('light-grey'),
            bg=self.colors('grey'),
            text="found local",
            width=54
        )
        self.found_label_s3 = Label(
            master,
            fg=self.colors('light-grey'),
            bg=self.colors('grey'),
            text="found s3",
            width=54
        )
        self.status_label = Label(
            master,
            fg=self.colors('light-grey'),
            bg=self.colors('grey'),
            text="Hello " + getuser(),
            width=54
        )
        self.create_bucket_label = Label(
            master,
            fg=self.colors('light-grey'),
            bg=self.colors('grey'),
            text="New Bucket:",
        )
        self.create_bucket_name = Text(
            master,
            fg=self.colors('cyan'),
            bg=self.colors('black'),
            width=25,
            height=1
        )
        self.create_bucket_button = Button(
            master,
            fg=self.colors('light-grey'),
            bg=self.colors('blue'),
            text="Create",
            width=5,
            highlightbackground=self.colors('black'),
            highlightthickness=2,
            command=self.create_bucket
        )
        # ####### begin grid placement ####### #
        self.title_label.grid(
            row=0,
            sticky=E+W,
            padx=20,
            pady=5
        )
        self.local_label.grid(
            row=0,
            sticky=W,
            padx=8,
            pady=5
        )
        self.s3_label.grid(
            row=0,
            sticky=E,
            padx=0,
            pady=5
        )
        self.browse_button.grid(
            row=1,
            sticky=W,
            padx=86,
            pady=10
        )
        self.dropdown_box.grid(
            row=1,
            sticky=E,
            padx=86,
            pady=5
        )
        self.browse_label.grid(
            row=2,
            sticky=W,
            padx=86,
            pady=5
        )
        self.bucket_label.grid(
            row=2,
            sticky=E,
            padx=86,
            pady=5
        )
        self.refresh_btn_local.grid(
            row=3,
            sticky=W,
            padx=86,
            pady=10
        )
        self.refresh_btn_s3.grid(
            row=3,
            sticky=E,
            padx=86,
            pady=10
        )
        self.explorer_label_local.grid(
            row=4,
            sticky=W,
            padx=20
        )
        self.explorer_label_s3.grid(
            row=4,
            sticky=E,
            padx=20
        )
        self.ex_loc.grid(
            row=4,
            sticky=W,
            padx=20
        )
        self.ex_s3.grid(
            row=4,
            sticky=E,
            padx=20
        )
        self.upload_button.grid(
            row=5,
            sticky=W,
            padx=224,
            pady=0
        )
        self.download_button.grid(
            row=5,
            sticky=E,
            padx=224,
            pady=0
        )
        self.delete_local.grid(
            row=5,
            sticky=W,
            padx=20,
            pady=0
        )
        self.delete_s3.grid(
            row=5,
            sticky=E,
            padx=20,
            pady=0
        )
        self.found_label_local.grid(
            row=6,
            sticky=W,
            padx=0,
            pady=20
        )
        self.found_label_s3.grid(
            row=6,
            sticky=E,
            padx=0,
            pady=20
        )
        self.status_label.grid(
            row=7,
            sticky=W,
            padx=0,
            pady=20
        )
        self.create_bucket_label.grid(
            row=7,
            sticky=E,
            padx=330,
            pady=0
        )
        self.create_bucket_name.grid(
            row=7,
            sticky=E,
            padx=100,
            pady=0
        )
        self.create_bucket_button.grid(
            row=7,
            sticky=E,
            padx=20,
            pady=0
        )
        n1 = "%s files found" % str(self.ex_loc.size())
        self.set_found_local_label(n1)
        n2 = "%s files found" % str(self.ex_s3.size())
        self.set_found_s3_label(n2)

    def quit(self):
        exit()

    def get_local_sel(self):
        return (self.ex_loc.get(i) for i in self.ex_loc.curselection())

    def get_s3_sel(self):
        return (self.ex_s3.get(i) for i in self.ex_s3.curselection())

    def set_drop_val(self, selection):
        self.drp_sel = selection

    def delete_local_records(self):
        files = self.get_local_sel()
        if not files:
            message = "Please select a file(s) to delete"
            self.set_status_label(message)
        else:
            self.del_local(files)

    def del_local(self, files_remaining):
        if len(files_remaining) > 0:
            f = files_remaining.pop(0)
            if not isdir(self.dir + "/" + f):
                try:
                    remove("%s/%s" % (self.dir, f))
                except Exception as err:
                    self.set_status_label("%s" % err)
                    self.status_label.update_idletasks()
                self.del_local(files_remaining)
            else:
                try:
                    rmtree("%s/%s" % (self.dir, f))
                except Exception as e:
                    self.set_status_label("%s" % e)
                    self.status_label.update_idletasks()
                self.del_local(files_remaining)
        self.deleted = True
        self.refresh_local()

    def delete_s3_records(self):
        removal = ''
        if not self.drp_sel:
            m = "Please select a bucket..."
            self.set_status_label(m)
        else:
            removal = self.get_s3_sel()
        if not removal:
            m = "Please select at least 1 object to delete"
            self.set_status_label(m)
        else:
            bucket = self.s3.Bucket(self.drp_sel)
            for rm in removal:
                for k in bucket.objects.all():
                    if k.key != rm:
                        continue
                    k.delete()
                    break
            self.deleted = True
            self.refresh_s3()

    def load_dir(self):
        self.dir = askdirectory()
        self.set_local_browse_label(self.dir)

    def refresh_local(self):
        if not self.dir:
            m = "Use the browse button to select a directory"
            self.set_status_label(m)
        else:
            self.set_local_browse_label(self.dir)
            self.ex_loc.delete(0, 'end')
            x = self.dir + "/"
            d = (f if not isdir(x+f) else f + '/' for f in sorted(listdir(x)))
            self.ex_loc.insert('end', *d)
            if not self.deleted:
                m = "Hello %s" % getuser()
            else:
                m = "FINISHED DELETING"
                self.deleted = False
            self.set_status_label(m)
            n = "%s files found" % str(self.ex_loc.size())
            self.set_found_local_label(n)

    def refresh_s3(self):
        if 'none available' in self.dropdown_data:
            m = "Please create at least one S3 bucket"
            self.set_status_label(m)
        elif not self.drp_sel:
            m = "Please select a bucket from the drop-down list"
            self.set_status_label(m)
        else:
            self.ex_s3.delete(0, 'end')
            self.ex_s3.insert('end', *self.get_bucket_contents())
            self.set_status_label("Hello %s" % getuser())
            self.set_s3_bucket_label(self.drp_sel)
            n = "%s files found" % str(self.ex_s3.size())
            self.set_found_s3_label(n)
            self.found_label_s3.update_idletasks()
            if not self.deleted:
                m = "Hello %s" % getuser()
            else:
                m = "FINISHED DELETING"
                self.deleted = False
            self.set_status_label(m)

    def finished(self, incoming_message):
        d = "FINISHED %s" % incoming_message
        for letter in enumerate(d):
            self.set_status_label(d(0:letter(0) + 1))
            self.status_label.update_idletasks()
            sleep(.1)

    def upload(self):
        if not self.drp_sel or not self.dir:
            m = "Ensure a local path and S3 bucket are selected"
            self.set_status_label(m)
        elif not self.get_local_sel():
            m = "Ensure files are selected to upload"
            self.set_status_label(m)
        else:
            for selection in self.get_local_sel():
                file_ = "%s/%s" % (self.dir, selection)
                if not isdir(file_):
                    self.s3c.upload_file(file_, self.drp_sel, basename(file_))
                else:
                    zipd = make_archive(file_, 'zip', self.dir, selection)
                    self.s3c.upload_file(zipd, self.drp_sel, basename(zipd))
                    remove(zipd)
                m = "Uploaded: %s" % selection
                self.set_status_label(m)
                self.status_label.update_idletasks()
            self.refresh_s3()
            self.finished("UPLOAD")

    def download(self):
        if not self.drp_sel or not self.dir:
            m = "Ensure a file and bucket have been selected"
            self.set_status_label(m)
        elif not self.get_s3_sel():
            m = "Ensure files are selected to download"
            self.set_status_label(m)
        else:
            for selection in self.get_s3_sel():
                file_ = "%s/%s" % (self.dir, selection)
                self.s3c.download_file(self.drp_sel, selection, file_)
            self.refresh_local()
            self.finished("DOWNLOAD")

    def get_bucket_contents(self):
        bucket = self.s3.Bucket(self.drp_sel)
        return (s3_file.key for s3_file in bucket.objects.all())

    def populate_dropdown(self):
        return (bucket.name for bucket in self.s3.buckets.all())

    def set_local_browse_label(self, incoming):
        if len(incoming) > 35:
            self.browse_label.config(text=basename(incoming) + '/')
        else:
            self.browse_label.config(text=incoming)

    def set_s3_bucket_label(self, incoming):
        self.bucket_label.config(text=incoming)

    def set_status_label(self, incoming):
        self.status_label.config(text=incoming)

    def set_found_local_label(self, incoming):
        self.found_label_local.config(text=incoming)

    def set_found_s3_label(self, incoming):
        self.found_label_s3.config(text=incoming)

    def create_bucket(self):
        self.bucket_name = self.create_bucket_name.get("1.0", END).strip()
        if not self.bucket_name:
            m = "Please enter a new bucket name"
            self.set_status_label(m)
        else:
            pre_exists = False
            try:
                self.s3.create_bucket(Bucket=self.bucket_name)
            except ClientError as ce:
                pre_exists = True
                m = "Bucket name is already in use. "
                m += "Choose a different name."
                self.set_status_label(m)
            if not pre_exists:
                m = "%s created: restarting..." % self.bucket_name
                self.set_status_label(m)
                self.status_label.update_idletasks()
                res = executable
                execl(res, res, *argv)


if __name__ == "__main__":
    root = Tk()
    s3_zilla = S3Zilla(root)
    root.mainloop()

Zero Parallel Affiliate Program | Money Maker Discussion

Never participate in affiliate programs if David Gasparyan appears there. This person has already been held accountable by the Office of Financial Consumer Protection twice and has paid fines. First, Gasparyan opened T3Leads, which, under his leadership, sold consumer loans and installment payments to lenders who, he knew, could issue invalid loans that lenders did not have the legal right to collect. Then, cheated consumers filed complaints against him at the CFPB, which took the necessary measures against these scammers and forced them to pay a fine. But it is clear that this did not serve as a lesson for David Gasparyan and again opens the partnership program of Zero Parallel LLC, which also leads consumers to bad or illegal transactions. After which, the Office again orders Zero Parallel and David Gasparyan to pay $ 350,000 and stop their abuse. But will this person stop?

Advanced Do Not Disturb Program

I would like to have Do not disturb automatically activated during the following times:

Monday: 9 a.m. at 1:30 p.m., 4 p.m. at 6 p.m.
Tuesday, Thursday and Friday from 9 a.m. at 1 p.m.
Wednesday: 9 a.m. at 1:30 p.m., 4:30 p.m. at 8:30 p.m.

Do not disturb in Configuration only supports the configuration of a block of time that is enabled or disabled for one day. So, if I didn't want to manually enable and disable Do not disturb, I would have to set something like 9 a.m. at 8:30 p.m. every day of the week, which leaves very little time to receive notifications.

Are there any applications that can automatically enable and disable Do not disturb for this type of programming?

I have the Samsung Galaxy S9 +, Android 9.0 Pie. My phone is not rooted.

What is better to program Asp.net v / s java

What are the benefits of programming on asp.net and what are those of java?

Zomex Affiliate Program ~ web hosting, web hosting and design services templates | Many tools, free

Zomex specializes in web hosting templates that are offered in many formats, including WHMCS, WordPress, Blesta and HTML. We also provide web hosting, design services that include logos, banners, pets and software services, including WHMCS and WordPress. Our affiliate program is free and easy to join.

> Learn more / join the Zomex affiliate program <

Provide reseller accommodation?

If so, your client will need a template to start your web hosting business. That's where Zomex comes in. We offer premium web hosting templates for WHMCS, WordPress, Blesta, HTML and you can make up to $ 15 / sale promoting them to their customers.

We also provide services that would be vital for any new web hosting reseller including WHMCS installation and configuration, reseller account automation, logo / banner design, WHMCS modules and much more through Zomex.com All this add extra value to your reseller hosting offers to ensure that your customers make the best use of their reseller account and continue renew month after month.

The key to the best affiliate programs is the best products and support. We offer some of the best web hosting templates available and we are known for providing excellent support that has no comparison in the industry. We have also dedicated a lot of time to development tools and options for our affiliates, including banners, code snippets, iframe integration and more than 40 links to several pages on our website that give you total control.

—– Join the web hosting template affiliate program n. ° 1 —–

commissions

Templates

– WordPress themes – $ 15.00 commission
– WHMCS Templates – $ 10.00 commission
– Blesta Templates – $ 7.00 commission
– HTML Templates – $ 7.00 commission

Services

– WHMCS configuration – $ 4.00 commission
– WHMCS Integration – $ 4.00 commission
– WHMCS update – $ 4.00 commission
– WHMCS Security – $ 4.00 commission
– WHMCS installation – $ 1.00 commission
– Logo design – $ 5.00 commission
– Banner design – $ 3.00 commission

Affiliate Program Features

We believe that we offer one of the best affiliate programs for web hosting templates, since we specialize in this field.

Many affiliate tools

—- awesome banners
—- more than 40 links to several landing pages (includes demo, sales page and payment page of all templates)
—- Ready-to-use HTML integration code: Instantly display the templates on your website. The code generates template feature boxes with order now, get more information and see demo links and an image of all templates. All this code also responds
—- Partner page – New! – Your own page on Zomex.com complete with your logo. All links on your page are affiliate links, so you will earn a commission for any purchase made from your page. This is a very fast and easy way to promote our templates and services to those of your customers.
– Reports and statistics in real time
– Fast and reliable payments
– Instant access to our program and tools.
– Free to join
– Access to affiliate support that can help with the implementation / integration of our tools

—– See our full range of affiliate resources —–

We look forward to hearing from you

If you have any questions, do not hesitate to answer this thread or contact our

sales department in sales (at) zomex com

or contact me personally at jack (at) zomex com

Thank you for showing interest in our services and have a great day!

a cordial greeting
Jack Curtis – CEO
Zomex.com

Python Open a window from an external program in windows

Good afternoon!

Guys, I'm writing a script using the PyAutoGui library. At some point, this script "needs to navigate between screens", for example, my script is working on a report within my TMS system and needs to go to a certain Excel screen.

How do I make my script always the right screen? Remember, I can get the PID of the program, using the Psutil library.

Thank you

Hostslim Affiliate Program: Pay while you wait!

We have just launched our new affiliate program on HostSlim with many benefits!

What we offer?

– Flat rate of your affiliate sales (10%)
– Pay whenever you want (no minimum deposit)
– Marketing elements
– Powerful control panel
– Multi language

Click here to see our affiliate program!

pandas: Python program that calculates the ideal presidential candidate based on job data?

I want to write a Python program that helps people determine the best democratic presidential candidate by comparing their positions with those of the candidates.

I have a panda data frame that looks like this:

    Issue1  Issue2
biden   yes no
booker  no  yes
sanders no  no

The idea is to create another column in the data frame to contain the scores of each candidate, such as df (& # 39; core_ candidate & # 39;).

The scores for each problem are generated by first asking the user about their personal position on the subject.

For example, "Does the green New Deal support? Yes / No": if the user input matches the candidate position (as shown in the data frame), the variable polarity is 1, otherwise -1.

The next question assesses the importance of the current topic. For example, "On a scale of 0-10, how important is the problem of the Green New Deal to you?"

So, if someone agrees with the candidate (positive polarity) and rates the problem as 10 important, then the score for that question would be 10.

Or, if someone does not agree with the candidate (negative polarity) but is not an important issue (for example, 2), then the score would be -2.

I want to be able to ask another question based on a different problem and add that score to the df column (& # 39; core_candidate & # 39;) to get a cumulative total.

Once the user has answered all the questions, I would like to print the main X candidates.

Can anyone give me some ideas on where to start with a program like this?

Thank you!

Configure the Windows Firewall entry rule for the program not installed on the server

How can I configure an entry rule in a Windows Server 2016 firewall to allow access from a program that is not installed on the server? When searching for a program, scanning is only available for locations on the server. Does the path specified for the rule apply to the machine that accesses the server? Is it possible to create a rule based only on the name of the executable program file, regardless of where it is installed on the machine accessing the server?

Which graphic program of inscriptions and texts is better for a web designer? – Everything else

Photoshop is the best program for image manipulation and graphic design. But I hate that Adobe has moved to its subscription model, where instead of paying once for the software, you pay a monthly fee. Macromedia should never have been sold to Adobe. That reduced competition.