Ejemplo n.º 1
0
def main():
    '''
    Main method
    '''
    args = parse_argument()

    if args.skip_verify:
        # This line is needed to suppress annoying warning message.
        urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

    print("current date and time is..")
    localtime = time.asctime(time.localtime(time.time()))
    print(localtime)

    oauth2 = PanoptoOAuth2(args.server, args.client_id, args.client_secret,
                           not args.skip_verify)

    uploader = PanoptoUploader(args.server, not args.skip_verify, oauth2,
                               args.username, args.password)
    video_link_url = uploader.upload_video(args.upload_file, args.folder_id)

    print("current date and time is..")
    localtime = time.asctime(time.localtime(time.time()))
    print(localtime)

    print(f"got video link url:{video_link_url}")
Ejemplo n.º 2
0
def main():
    args = parse_argument()

    if args.skip_verify:
        # This line is needed to suppress annoying warning message.
        urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

    # Use requests module's Session object in this example.
    # ref. https://2.python-requests.org/en/master/user/advanced/#session-objects
    requests_session = requests.Session()
    requests_session.verify = not args.skip_verify

    # Load OAuth2 logic
    oauth2 = PanoptoOAuth2(args.server, args.client_id, args.client_secret,
                           not args.skip_verify)

    # Load Folders API logic
    folders = PanoptoFolders(args.server, not args.skip_verify, oauth2)

    current_folder_id = GUID_TOPLEVEL

    while True:
        print('----------------------------')
        current_folder = get_and_display_folder(folders, current_folder_id)
        sub_folders = get_and_display_sub_folders(folders, current_folder_id)
        current_folder_id = process_selection(folders, current_folder,
                                              sub_folders)
Ejemplo n.º 3
0
def main():
    session = Session()
    session.verify = True
    oauth2 = PanoptoOAuth2(server, client_id, client_secret, cache_dir)
    folders = PanoptoFolders(server, True, oauth2)
    folder = folders.get_folder(folder_id)
    list_sessions(folders, folder)
Ejemplo n.º 4
0
def main():
    args = parse_argument()

    if args.skip_verify:
        # This line is needed to suppress annoying warning message.
        urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

    # Use requests module's Session object in this example.
    # ref. https://2.python-requests.org/en/master/user/advanced/#session-objects
    requests_session = requests.Session()
    requests_session.verify = not args.skip_verify
    
    # Load OAuth2 logic
    oauth2 = PanoptoOAuth2(args.server, args.client_id, args.client_secret, not args.skip_verify)

    # Initial authorization
    authorization(requests_session, oauth2)

    # Call Panopto API (getting sub-folders from top level folder) repeatedly
    folder_id = '00000000-0000-0000-0000-000000000000' # represent top level folder
    while True:
        print('Calling GET /api/v1/folders/{0}/children endpoint'.format(folder_id))
        url = 'https://{0}/Panopto/api/v1/folders/{1}/children'.format(args.server, folder_id)
        resp = requests_session.get(url = url)
        if inspect_response_is_unauthorized(resp):
            # Re-authorization
            authorization(requests_session, oauth2)
            # Re-try now
            continue
        data = resp.json() # parse JSON format response
        for folder in data:
            print('  {0}: {1}'.format(folder['Id'], folder['Name']))
        time.sleep(60)
Ejemplo n.º 5
0
def main():
    args = parse_argument()

    if args.skip_verify:
        # This line is needed to suppress annoying warning message.
        urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

    # Use requests module's Session object in this example.
    # ref. https://2.python-requests.org/en/master/user/advanced/#session-objects
    requests_session = requests.Session()
    requests_session.verify = not args.skip_verify

    # Load OAuth2 logic
    oauth2 = PanoptoOAuth2(args.server, args.client_id, args.client_secret,
                           not args.skip_verify)

    # Load Sessions API logic
    sessions = PanoptoSessions(args.server, not args.skip_verify, oauth2)

    if args.session_id is not None:
        current_session_id = args.session_id
    else:
        current_session_id = None

    # Load the initial session (if any) and display the options menu
    while True:
        print('----------------------------')
        if current_session_id is not None:
            session = get_and_display_session(sessions, current_session_id)

        current_session_id = process_selection(sessions, current_session_id)
    def upload_and_create_link(self, full_file_path, course_uuid):
        print("current date and time is..")
        localtime = time.asctime(time.localtime(time.time()))
        print(localtime)
        print("file: " + full_file_path)
        print("course_uuid: " + course_uuid)
        print("fcourse_uuid: " + f"uuid:{course_uuid}")
        ssl_verify = True
        basename = ntpath.basename(full_file_path)
        (course_name, ext) = os.path.splitext(basename)

        # oauth2 = PanoptoOAuth2(self.ppto_server, self.ppto_client_id, self.ppto_client_secret, not args.skip_verify)
        oauth2 = PanoptoOAuth2(self.ppto_server, self.ppto_client_id, self.ppto_client_secret, ssl_verify) 

        uploader = PanoptoUploader(self.ppto_server, ssl_verify, oauth2, self.ppto_username, self.ppto_password)
        video_link_url = uploader.upload_video(full_file_path, self.ppto_folder_id)

        print("current date and time is..")
        localtime = time.asctime(time.localtime(time.time()))
        print(localtime)

        print (f"got video link url:{video_link_url} creating link in {course_uuid} on {self.learn_rest_fqdn}")
        
        link_creator = VideoLinkCreator(self.learn_rest_fqdn, self.learn_rest_key, self.learn_rest_secret, f"uuid:{course_uuid}", video_link_url, course_name, "DevCon session recording brought to you by Blackboard Collaborate and Panopto")
        link_creator.create_video_link()
        print("Link is in the course. That's all folks!")
Ejemplo n.º 7
0
def main():
    '''
    Main method
    '''
    args = parse_argument()

    if args.skip_verify:
        # This line is needed to suppress annoying warning message.
        urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

    oauth2 = PanoptoOAuth2(args.server, args.client_id, args.client_secret, not args.skip_verify)

    uploader = UcsUploader(args.server, not args.skip_verify, oauth2)
    uploader.upload_folder(args.local_folder, args.folder_id)
Ejemplo n.º 8
0
def main(is_manual, is_main=True, is_fast=False):
    global data, uploader, course_names, sheet_full_data, sheet, full_data
    scope = [
        'https://spreadsheets.google.com/feeds',
        'https://www.googleapis.com/auth/drive'
    ]
    creds = ServiceAccountCredentials.from_json_keyfile_name(
        config.GOOGLE_JSON, scope)
    client = gspread.authorize(creds)
    sheet = client.open("StreamitUP to Panopto DB").sheet1
    sheet_full_data = client.open('Full StreamitUP Data').sheet1
    data = safe_get_df(sheet)
    full_data = safe_get_df(sheet_full_data)
    # xml_strs = full_data['XML'].values
    course_names = data['COURSE_NAME'].values
    urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
    oauth2 = PanoptoOAuth2(config.PANOPTO_SERVER_NAME,
                           config.PANOPTO_CLIEND_ID, config.PANOPTO_SECRET,
                           False)
    uploader = UcsUploader(config.PANOPTO_SERVER_NAME, False, oauth2)

    upload(is_manual, is_main, is_fast)
Ejemplo n.º 9
0
import keyring

from panopto_oauth2 import PanoptoOAuth2

panopto_server = "cornell.hosted.panopto.com"

panopto_clientid = getpass.getpass("Enter panopto client id :\n")
keyring.set_password("panopto_clientid", "panopto", panopto_clientid)

panopto_clientsecret = getpass.getpass("Enter panopto client secret:\n")
keyring.set_password("panopto_clientsecret", "panopto", panopto_clientsecret)

panopto_clientid = keyring.get_password("panopto_clientid", "panopto")
panopto_clientsecret = keyring.get_password("panopto_clientsecret", "panopto")

oauth2 = PanoptoOAuth2(panopto_server, panopto_clientid, panopto_clientsecret,
                       False)


def authorization(requests_session, oauth2):
    # Go through authorization
    access_token = oauth2.get_access_token_authorization_code_grant()
    # Set the token as the header of requests
    requests_session.headers.update(
        {'Authorization': 'Bearer ' + access_token})


requests_session = requests.Session()
requests_session.verify = False

authorization(requests_session, oauth2)
Ejemplo n.º 10
0
def main():
    args = parse_argument()
    panoptoSiteLocation = "https://" + args.server

    if args.skip_verify:
        # This line is needed to suppress annoying warning message.
        urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

    # Use requests module's Session object in this example.
    # ref. https://2.python-requests.org/en/master/user/advanced/#session-objects
    requests_session = requests.Session()
    requests_session.verify = not args.skip_verify

    # Load OAuth2 logic
    oauth2 = PanoptoOAuth2(args.server, args.client_id, args.client_secret,
                           not args.skip_verify)

    # Load Folders API logic
    folders = PanoptoFolders(args.server, not args.skip_verify, oauth2)

    current_folder_id = GUID_TOPLEVEL
    print("\n-------------")

    print(
        "\nWelcome to the Panopto Folder Renaming/Moving Tool folders to be processed should be in "
        + csvLocation + " and the results will be stored in " + resultsCsv)
    print("You are logged into " + panoptoSiteLocation)

    print("\n-------------")
    print("What Subject is being processed? (eg. Biology)")
    newSubjectFolder = search_folder(folders)
    subjectFolder = newSubjectFolder[0]
    print("-------------")

    # Display and select Subfolders
    subFolder = get_and_select_sub_folders(folders, subjectFolder)
    print("-------------")

    # Check if selected folder is correct
    print("Once confirmed the script will start iterating through the " +
          csvLocation + " file and rename/move the folders")
    print("\nYou have selected the subject: " + newSubjectFolder[1] +
          "\nYou have selected the subfolder: " + subFolder[1])
    print("\n-------------")
    doubleCheck = input(
        "Please confirm if the above settings are correct: (y) ")
    if doubleCheck.lower() != 'y':
        exit()

    # Select correct folder
    print("---------")

    with open(resultsCsv, mode='w') as resultsCsvfile:
        fieldnames = ['oldName', 'newName', 'success', 'urlLink']
        csv_writer = csv.DictWriter(resultsCsvfile, fieldnames=fieldnames)
        csv_writer.writeheader()

        with open(csvLocation, newline='') as csvfile:
            reader = csv.DictReader(csvfile)
            for row in reader:
                # Find and Move Folder
                newFolderName = row['newName']

                print("Module Code: " + newFolderName)
                print("Searching for: " + row['oldName'])
                oldFolderName = search_folder_with_query(
                    folders, row['oldName'])

                success = "N"
                urlLink = 'Folder Not Found'

                if (row['oldName'] == "null-shared"):
                    urlLink = 'TO CHECK - SHARED'

                if (str(oldFolderName) != "None"):
                    if (doubleVerify == True):
                        verify = input(
                            "Are you sure? (enter 'y' to continue or 'n' to abort)"
                        )
                    else:
                        verify = 'y'

                    if (verify.lower() == 'y'):
                        moveSuccess = False
                        nameSuccess = folders.update_folder_name(
                            oldFolderName, newFolderName)

                        if nameSuccess:
                            moveSuccess = folders.update_folder_parent(
                                oldFolderName, subFolder[0], subFolder[1])

                        if nameSuccess and moveSuccess == False:
                            print(
                                "Could not move due to conflict however renamed sucessfully!"
                            )
                            success = "Renamed but did not Move due to conflict"
                            renameSuccess = rename_and_move(
                                folders, oldFolderName, newFolderName,
                                subFolder)
                            if renameSuccess:
                                print("Renamed and Moved Sucessfully!")
                                success = "Y - modified name"

                        if nameSuccess == False and moveSuccess == False:
                            print(
                                "Could not rename or move! - This is due to the folder name already being "
                                "present in the parent directory")
                            success = "N - Failed please try manually"

                        if nameSuccess and moveSuccess:
                            success = "Y"
                        urlLink = panoptoSiteLocation + "/Panopto/Pages/Sessions/List.aspx#folderID=" + oldFolderName

                csv_writer.writerow({
                    'oldName': str(row['oldName']),
                    'newName': str(row['newName']),
                    'success': success,
                    'urlLink': urlLink
                })
                print("---------")