def __init__(self): self.platform = "Windows" if sys.platform.startswith( "win") else "Mac" if sys.platform == "darwin" else "Linux" version_file = getFileName("dependency_versions.json") if version_file is None: raise ValueError("dependency_versions.json was not found.") with open(version_file, "r") as f: self.versions = json.load(f)
def __init__(self, loader): """ :param loader: @type loader: MaskGenLoader """ self.loader = loader fileName = getFileName('trello.json', path='trello_plugin') with open(fileName, 'r') as f: self.loaded_config = json.load(f)
def update_user_name(): import json from maskgen.software_loader import getFileName property_file = getFileName('project_properties.json') with open(property_file, 'r') as f: props = json.load(f) for prop in props['properties']: if prop['name'] == 'username': prop['type'] = 'listfromfile:ManipulatorCodeNames.txt' with open(property_file, 'w') as f: json.dump(props, f, indent=2, encoding='utf-8')
def loadS3(values): import boto3 import os logging.getLogger('maskgen').info( 'Download operations and software via S3') s3 = boto3.client('s3','us-east-1') BUCKET = values[0][0:values[0].find('/')] DIR=values[0][values[0].find('/')+1:] place = getFileName('operations.json') if place is None: place = os.path.abspath(os.getenv('MASKGEN_RESOURCES', '.')) else: place = os.path.dirname(place) s3.download_file(BUCKET, DIR + "/operations.json", os.path.join(place,"operations.json")) s3.download_file(BUCKET, DIR + "/software.csv", os.path.join(place,"software.csv")) s3.download_file(BUCKET, DIR + "/project_properties.json", os.path.join(place,"project_properties.json")) s3.download_file(BUCKET, DIR + "/ManipulatorCodeNames.txt", os.path.join(place, "ManipulatorCodeNames.txt"))
def loadHTTP(values): import requests import os logging.getLogger('maskgen').info( 'Download operations and software via HTTP') head = {} place = getFileName('operations.json') if place is None: place = os.path.abspath(os.getenv('MASKGEN_RESOURCES', '.')) else: place = os.path.dirname(place) for p in range(1, len(values)): name = values[p].split(':')[0].strip() val = values[p].split(':')[1].strip() head[name]=val r = requests.get(values[0] + '/operations.json',headers=head) if r.status_code < 300: with open(os.path.join(place,"operations.json"), 'w') as f: f.write(r.content) r = requests.get(values[0] + '/software.csv',headers=head) if r.status_code < 300: with open(os.path.join(place,"software.csv"), 'w') as f: f.write(r.content)
def setup_window(self): r = 0 # Info heading info_text = Label( text= "Enter all of the following\ninformation in order to guarantee\nproper setup of" " the Journaling Tool\nand High Provenance Tool.\nFields marked with an * are" " mandatory") info_text.grid(row=r, columnspan=2, pady=5) r += 1 ufile = getFileName("ManipulatorCodeNames.txt") if ufile: with open(ufile, "r") as names: self.valid_usernames = sorted(names.read().splitlines()) else: self.valid_usernames = [] self.maskgen_button = Button(text="Select Maskgen Folder", command=self.get_maskgen) self.maskgen_button.grid(row=r, column=0, columnspan=2) r += 1 self.master.withdraw() tkMessageBox.showerror("No Username File", "A username list file could not be found.") self.master.deiconify() # General Header general_label = Label(text="General Setup") general_label.grid(row=r, columnspan=2) r += 1 # API URL self.apiurl_label = Button(text="API URL*", command=lambda: self.get_info("apiurl")) self.apiurl_label.grid(row=r, column=0, padx=10) self.apiurl_field = Entry() self.apiurl_field.grid(row=r, column=1, padx=10) r += 1 # Browser Username self.busername_label = Button( text="Browser Username*", command=lambda: self.get_info("busername")) self.busername_label.grid(row=r, column=0, padx=10) self.busername_field = Entry() self.busername_field.grid(row=r, column=1, padx=10) r += 1 # Browser Password self.bpassword_label = Button( text="Browser Password*", command=lambda: self.get_info("bpassword")) self.bpassword_label.grid(row=r, column=0, padx=10) self.bpassword_field = Entry(show="*") self.bpassword_field.grid(row=r, column=1, padx=10) r += 1 # Username self.username_label = Button(text="Username*", command=lambda: self.get_info("username")) self.username_label.grid(row=r, column=0, padx=10) self.username_field = ttk.Combobox(values=self.valid_usernames) self.username_field.grid(row=r, column=1, padx=10) r += 1 # JT Setup jt_setup = Label(text="Journaling Tool Setup") jt_setup.grid(row=r, columnspan=2, pady=5) r += 1 # Organization self.organization_label = Button( text="Organization*", command=lambda: self.get_info("organization")) self.organization_label.grid(row=r, column=0, padx=10) self.organization_field = Entry() self.organization_field.grid(row=r, column=1, padx=10) r += 1 # Journal Upload Folder self.jt_uploadfolder_label = Button( text="Journal Upload Folder", command=lambda: self.get_info("uploadfolder")) self.jt_uploadfolder_label.grid(row=r, column=0, padx=10) self.jt_uploadfolder_field = Entry() self.jt_uploadfolder_field.grid(row=r, column=1, padx=10) r += 1 # HP Tool Setup jt_setup = Label(text="High Provenance Tool Setup") jt_setup.grid(row=r, columnspan=2, pady=5) r += 1 # High Provenance Upload Folder self.hpupload_button = Button( text="HP Upload Folder", command=lambda: self.get_info("uploadfolder")) self.hpupload_button.grid(row=r, column=0, padx=10) self.hpupload_field = Entry(self.parent) self.hpupload_field.grid(row=r, column=1, padx=10) r += 1 # PRNU Upload Folder self.prnuupload_button = Button( text="PRNU Upload Folder", command=lambda: self.get_info("uploadfolder")) self.prnuupload_button.grid(row=r, column=0, padx=10) self.prnuupload_field = Entry(self.parent) self.prnuupload_field.grid(row=r, column=1, padx=10) r += 1 # Submit Button submit = Button(text="Submit", command=lambda: self.submit_data()) submit.grid(row=r, column=0, padx=10, pady=5) # Help Button help = Button(text="Help", command=lambda: self.get_info("help")) help.grid(row=r, column=1, padx=10, pady=5)
# Always retry when an apiclient.errors.HttpError with one of these status # codes is raised. RETRIABLE_STATUS_CODES = [500, 502, 503, 504] # The CLIENT_SECRETS_FILE variable specifies the name of a file that contains # the OAuth 2.0 information for this application, including its client_id and # client_secret. You can acquire an OAuth 2.0 client ID and client secret from # the Google Developers Console at # https://console.developers.google.com/. # Please ensure that you have enabled the YouTube Data API for your project. # For more information about using OAuth2 to access the YouTube Data API, see: # https://developers.google.com/youtube/v3/guides/authentication # For more information about the client_secrets.json file format, see: # https://developers.google.com/api-client-library/python/guide/aaa_client_secrets CLIENT_SECRETS_FILE = software_loader.getFileName('client_secrets.json') OAUTH_FILE = software_loader.getFileName('youtube-oauth2.json') # This OAuth 2.0 access scope allows an application to upload files to the # authenticated user's YouTube channel, but doesn't allow other types of access. YOUTUBE_UPLOAD_SCOPE = "https://www.googleapis.com/auth/youtube" YOUTUBE_API_SERVICE_NAME = "youtube" YOUTUBE_API_VERSION = "v3" # This variable defines a message to display if the CLIENT_SECRETS_FILE is # missing. MISSING_CLIENT_SECRETS_MESSAGE = """Please configure OAuth 2.0 To run this plugin, you will need to place a populated client_secrets.json file in maskgen/resources. If there is one there already, it is invalid.