Exemplo n.º 1
0
 def _tk_folder_selection(self) -> str:
     """ returns path to main folder of what the user selects via a GUI/prompt """
     root = Tk()
     root.withdraw()
     path = askdirectory(title='Please select a folder')
     root.destroy()
     return path
Exemplo n.º 2
0
def write_tracklist():
    root = Tk()
    root.withdraw()
    files = askopenfilenames(parent=root, title="Choose Tracks")
    tracklist = root.tk.splitlist(files)
    for to_write in tracklist:
        write_lyrics_with_path(to_write, True)
    print("Done!")
Exemplo n.º 3
0
 def _tk_file_selection(self) -> str:
     """ returns full path of a file that the user selects via a GUI/prompt """
     self.is_user_selected_directory = True
     root = Tk()
     root.withdraw()
     path = askopenfilename(title='Please select a file')
     root.destroy()
     return path
Exemplo n.º 4
0
def main():
    """ Main Program """

    # Parser for user CLI interaction
    parser = ArgumentParser(
        description=
        'Provided a list of IP addresses or URL\'s, format the proper Fortigate '
        'commands to create them and output to a file within the current working directory.\n'
        'DISCLAIMER: If you run something on a firewall that you shouldn\'t have, '
        'we are NOT responsible. READ YOUR CODE BEFORE YOU PLACE IT!!!',
        usage='VDOM input_file.txt or .csv',
        formatter_class=RawTextHelpFormatter)
    parser.add_argument(
        '-v',
        '--VDOM',
        help='Specify the VDOM to which changes will be applied.\n\n',
        default=False)
    parser.add_argument(
        '-f',
        '--File',
        help='Accepts two kinds of files, .txt & .csv. If no file is given, '
        'the file explorer will launch and you will be prompted to select one.\n'
        'Each type should be formatted differently.\n'
        '.txt: Each entry should be on its own line, formatted as IP/CIDR, IP/Netmask or a URL.\n'
        '.csv: Should consist of 5 fields.  The first is required, the rest are optional:\n\n'
        'IP/CIDR or URL (the CIDR prefix is optional, and just an IP can be accepted)\n'
        'Netmask (needed if you do not provide a CIDR in the previous field)\n'
        'Custom Name for the object\n'
        'Interface to associate object to\n'
        'Comment to label the object\n\n'
        '.csv\'s should be formatted similarly to an Excel .csv')
    address_or_service = parser.add_mutually_exclusive_group()
    address_or_service.add_argument('-a',
                                    '--address',
                                    default=True,
                                    action='store_true',
                                    help='Create address objects.')
    address_or_service.add_argument('-s',
                                    '--service',
                                    default=False,
                                    action='store_true',
                                    help='Create service objects.')
    args = parser.parse_args()

    # If args.File is given, proceed to launch function. Else, launch file
    # explorer and then proceed.
    if args.File:
        launch(args.VDOM, args.File, args.address, args.service)
    else:
        root = Tk()
        root.withdraw()  # Prevents empty root window from displaying.
        launch(args.VDOM, askopenfilename(), args.address, args.service)
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.'''


from tkinter.filedialog import askopenfilename, asksaveasfilename, Tk
import csv

#Prevent tk window from displaying
root = Tk()
root.withdraw()

appointments = {}
currentPatient = ''
#Select whether to output patient # (anonymous = True) or patient name (anonymous = False)
anonymous = True

#Get user to select a file
filename = askopenfilename(title='Select a PSS patient appointment report to analyze')
temp = filename.rsplit(".", 1) #split off "txt" extension
temp.insert(1, "reformat") #insert "reformat" before extension
output = ".".join(temp) #join back together into one string

with open(filename, 'r') as f:
    reformatted = []
    num_cols = 0
from xml.etree import ElementTree as Elem
import os.path
from tkinter.filedialog import askopenfilename, asksaveasfilename, Tk
window = Tk()
window.withdraw()
window.focus_force()

# tree = Elem.parse("C:\\Users\\Jason\\Desktop\\bi-dir-test.xml")
tree = Elem.parse(
    askopenfilename(initialdir=os.path.expanduser("~/Desktop"),
                    title="Select Palo Alto xml configuration file."))
# root_tree = tree.getroot()

nat_dict = {}
nat_policy_count = 0
for elem in tree.iter(tag="nat"):
    for rules in elem:
        for entry in rules:
            nat_policy_count += 1
            rule_dic = {"bi_d": 'no'}
            # print(entry.tag, entry.attrib)
            nat_dict[entry.attrib["name"]] = rule_dic

            for member in entry.find("source"):
                nat_dict[entry.attrib["name"]]["source"] = member.text
                # print(member.text)

            for member in entry.find("destination"):
                nat_dict[entry.attrib["name"]]["destination"] = member.text
                # print(member.text)
def clean_file_selection(text):
    root = Tk()
    root.withdraw()
    path = askopenfilename(title=text)
    root.destroy()
    return path
def clean_path_selection(text):
    root = Tk()
    root.withdraw()
    path = askdirectory(title=text, mustexist=True)
    root.destroy()
    return path
Exemplo n.º 9
0
    # replace all floats
    s = re.sub('"[-+]?(\d+([.,]\d*)?|[.,]\d+)([eE][-+]?\d+)?"', lambda f: str(float(f[0][1:-1])), s)
    return s


def copy_binaries(wd, fmus, binaries):
    primary = basename(fmus[0])
    for fmu, binaries_ in zip(fmus[1:], binaries[1:]):
        for binary in binaries_:
            copytree(join(wd, basename(fmu), 'binaries', binary), join(wd, primary, 'binaries', binary))


if __name__ == '__main__':
    tk = Tk()
    tk.withdraw()

    fmus = askopenfilenames(title='Select FMUs to merge', filetypes=['Functional\u00A0Mockup\u00A0Unit {*.fmu}'])

    if len(fmus) < 2:
        raise ValueError('Please select multiple FMUs')

    # create tmp directory
    with TemporaryDirectory() as dir:
        # unpack fmus to tmp directory
        binaries = []
        for fmu in fmus:
            with ZipFile(fmu, 'r') as z:
                z.extractall(join(dir, basename(fmu)))
            # add all subdirectories of "binaries" in the zip files
            binaries.append(list(filter(lambda f: not isdir(f), listdir(join(dir, basename(fmu), "binaries")))))
import csv
import datetime
import os
import openpyxl
from openpyxl.styles import Font, PatternFill
from tkinter.filedialog import askopenfilename, asksaveasfilename, Tk
# from tkinter import messagebox
# Tk().withdraw()  # Prevents tkinter window from opening
root = Tk()
root.withdraw()
root.focus_force()
now = datetime.datetime.now().strftime("%m/%d/%Y")


def mode_1_import():
    """

    :return: dictionary {rulename: [set(apps), set(dest_port/protocol), hit value(T/F)]
    """
    rules_dict = None  # Eliminates Pycharm Error
    unk_tu_dict = {}  # dict for unknown tcp and udp log entries
    # parse ruleset and get rule names and details
    try:
        with open(
                askopenfilename(
                    initialdir=os.path.expanduser("~/Desktop"),
                    title=
                    "Select Security Rules CSV exported from Palo Alto firewall."
                )) as rules_file:
            # with open("C:\\Users\\Jason\\Desktop\\policies.csv") as rules_file: