def getUserReport():
	csvUserFile = csv.writer(open("allUserReport.csv", "wb+"))
	csvUserFile.writerow(csvUserHeaders)

	users = c42Lib.getAllUsers()
	for index, user in enumerate(users):
		# user = c42Lib.getUserById('6031')
		# user = c42Lib.getUserById('7403')

		printRow = []

		pUserId = user['userId']
		printRow.extend([str(pUserId)])

		pUserName = user['username']
		printRow.extend([pUserName.encode('utf-8')])

		pUserEmail = user['email']
		if pUserEmail is not None:
			printRow.extend([pUserEmail.encode('utf-8')])
		else:
			printRow.extend([emptyBlock])

		pUserOrgId = user['orgId']
		printRow.extend([str(pUserOrgId)])

		pUserOrgName = user['orgName']
		printRow.extend([pUserOrgName.encode('utf-8')])

		if 'computerCount' in user:
			pUserComputerCount = user['computerCount']
			printRow.extend([str(pUserComputerCount)])
		else:
			printRow.extend([emptyBlock])


		if 'backupUsage' in user:

			userBackupUsage = user['backupUsage']

			if userBackupUsage:

				if 'archiveHistory' in userBackupUsage[0]:

					userBackupUsageArchiveHistory = userBackupUsage[0]['archiveHistory']

					if userBackupUsageArchiveHistory:

						oldestDate = 9999999999999999999
						# "20130801": 1909986568291,
						oldestDateBytes = 0
						newestDate = 0
					    # "20130830": 1932985363857
						newestDateBytes = 0

						for key, value in userBackupUsageArchiveHistory.items():
							# print key, value
							# print oldestDate, int(key)
							if (oldestDate > int(key)):
								oldestDate = int(key)
								oldestDateBytes = value
							
							# print newestDate, int(key)
							if (newestDate <= int(key)):
								newestDate = int(key)
								newestDateBytes = value

						printRow.extend([str(oldestDate)])
						printRow.extend([str(oldestDateBytes)])
						printRow.extend([c42Lib.sizeof_fmt(oldestDateBytes)])

						printRow.extend([str(newestDate)])
						printRow.extend([str(newestDateBytes)])
						printRow.extend([c42Lib.sizeof_fmt(newestDateBytes)])


						pArchiveBytesDeltaMonth = userBackupUsage[0]['archiveBytesDeltaMonth']
						printRow.extend([str(pArchiveBytesDeltaMonth)])
						printRow.extend([c42Lib.sizeof_fmt(pArchiveBytesDeltaMonth)])


						# pArchiveBytesDeltaMonthSanityCheck = newestDateBytes - oldestDateBytes
						# printRow.extend([str(pArchiveBytesDeltaMonthSanityCheck)])
						# printRow.extend([c42Lib.sizeof_fmt(pArchiveBytesDeltaMonthSanityCheck)])

						
					else:
						printUserEmptyBlock()
				
				else:
					printUserEmptyBlock()

		else:
			printUserEmptyBlock()

		logging.info(str(printRow))
		csvUserFile.writerow(printRow)
Exemple #2
0
def getUserReport():
    logging.info("User Export Action: startDate:" + cp_startDate +
                 " | deltaTime: " + str(cp_deltaDate) + " | loggingLevel: " +
                 cp_logLevel)
    csvUserFile = csv.writer(
        open("ExportAllUserDataCreateDateReport.csv", "wb+"))
    csvUserFile.writerow(csvUserHeaders)

    start_date_object = ""
    # end_date_object = ""

    start_date_object = datetime.datetime.strptime(cp_startDate, '%m/%d/%Y')
    # end_date_object = datetime.datetime.strptime(cp_endDate, '%m/%d/%Y')
    # print end_date_object

    emptyBlock = ""

    users = c42Lib.getAllUsers()
    # users = c42Lib.getUsers(1)
    for index, user in enumerate(users):
        # user = c42Lib.getUserById('6031')
        # user = c42Lib.getUserById('7403')

        printRow = []

        creationDate = ""
        if 'creationDate' in user:
            creationDate = user['creationDate']

        currDateObj = ""
        deltaTime = ""

        if creationDate is not None:
            currDateObj = datetime.datetime.strptime(
                str(creationDate)[:10], "%Y-%m-%d")
            deltaTime = start_date_object + relativedelta(
                months=+int(cp_deltaDate))

        # logging.info(str(currDateObj) + " delta: " + str(deltaTime))
        if deltaTime > currDateObj > start_date_object:

            pUserId = user['userId']
            # logging.info(str(pUserId))
            printRow.extend([str(pUserId)])

            pUserName = user['username']
            printRow.extend([pUserName.encode('utf-8')])

            pUserEmail = user['email']
            if pUserEmail is not None:
                printRow.extend([pUserEmail.encode('utf-8')])
            else:
                printRow.extend([emptyBlock])

            pUserOrgId = user['orgId']
            printRow.extend([str(pUserOrgId)])

            pUserOrgName = user['orgName']
            printRow.extend([pUserOrgName.encode('utf-8')])

            if 'computerCount' in user:
                pUserComputerCount = user['computerCount']
                printRow.extend([str(pUserComputerCount)])
            else:
                printRow.extend([emptyBlock])

            if 'creationDate' in user:
                pUserCreationDate = user['creationDate']
                printRow.extend([pUserCreationDate])

            if 'backupUsage' in user:

                userBackupUsage = user['backupUsage']

                if userBackupUsage:

                    if 'archiveHistory' in userBackupUsage[0]:

                        userBackupUsageArchiveHistory = userBackupUsage[0][
                            'archiveHistory']

                        if userBackupUsageArchiveHistory:

                            oldestDate = 9999999999999999999
                            # "20130801": 1909986568291,
                            oldestDateBytes = 0
                            newestDate = 0
                            # "20130830": 1932985363857
                            newestDateBytes = 0

                            for key, value in userBackupUsageArchiveHistory.items(
                            ):
                                # print key, value
                                # print oldestDate, int(key)
                                if (oldestDate > int(key)):
                                    oldestDate = int(key)
                                    oldestDateBytes = value

                                # print newestDate, int(key)
                                if (newestDate <= int(key)):
                                    newestDate = int(key)
                                    newestDateBytes = value

                            printRow.extend([str(oldestDate)])
                            printRow.extend([str(oldestDateBytes)])
                            printRow.extend(
                                [c42Lib.sizeof_fmt(oldestDateBytes)])

                            printRow.extend([str(newestDate)])
                            printRow.extend([str(newestDateBytes)])
                            printRow.extend(
                                [c42Lib.sizeof_fmt(newestDateBytes)])

                            pArchiveBytesDeltaMonth = userBackupUsage[0][
                                'archiveBytesDeltaMonth']
                            printRow.extend([str(pArchiveBytesDeltaMonth)])
                            printRow.extend(
                                [c42Lib.sizeof_fmt(pArchiveBytesDeltaMonth)])

                            # pArchiveBytesDeltaMonthSanityCheck = newestDateBytes - oldestDateBytes
                            # printRow.extend([str(pArchiveBytesDeltaMonthSanityCheck)])
                            # printRow.extend([c42Lib.sizeof_fmt(pArchiveBytesDeltaMonthSanityCheck)])

            # 			else:
            # 				printUserEmptyBlock()

            # 		else:
            # 			printUserEmptyBlock()

            # else:
            # 	printUserEmptyBlock()

            logging.info(str(printRow))
            csvUserFile.writerow(printRow)
        else:
            logging.debug("nothing to report")
Exemple #3
0
def getDeviceReport():
    csvDeviceFile = csv.writer(open("allDeviceReport.csv", "wb+"))
    csvDeviceFile.writerow(csvDeviceHeader)

    users = c42Lib.getAllUsers()
    # get all the users to have in memory

    devices = c42Lib.getAllDevices()
    # devices = c42Lib.getDevices(1)

    for index, device in enumerate(devices):
        # device = c42Lib.getDeviceById(8637)
        printValues = []

        # computerId = loopDevice['computerId']

        # device = c42Lib.getDeviceById(computerId)

        userId = device['userId']
        printValues.extend([str(userId)])

        # Lookup User Info
        userInfo = findRecord(userId, users)

        logging.debug(userInfo)

        #Get User Name
        if userInfo:
            userName = userInfo['username']
        else:
            username = '******'
        printValues.extend([userName.encode('utf-8')])

        # print deviceObject
        computerId = device['computerId']
        printValues.extend([str(computerId)])

        computerName = device['name']
        printValues.extend([computerName.encode('utf-8')])

        computerType = device['type']
        printValues.extend([computerType.encode('utf-8')])

        osName = device['osName']
        printValues.extend([osName.encode('utf-8')])

        computerStatus = device['status']
        printValues.extend([computerStatus.encode('utf-8')])

        if 'backupUsage' in device:

            deviceObjectBackupUsage = device['backupUsage']

            for backupUsage in deviceObjectBackupUsage:

                if backupUsage['targetComputerId'] == destId:

                    storePointId = backupUsage['storePointId']
                    printValues.extend([str(storePointId)])

                    storePointName = backupUsage['storePointName']
                    printValues.extend([storePointName.encode('utf-8')])

                    serverId = backupUsage['serverId']
                    printValues.extend([str(serverId)])

                    serverName = backupUsage['serverName']
                    printValues.extend([serverName.encode('utf-8')])

                    selectedFiles = backupUsage['selectedFiles']
                    printValues.extend([str(selectedFiles)])

                    selectedBytes = backupUsage['selectedBytes']
                    printValues.extend([str(selectedBytes)])

                    printValues.extend([c42Lib.sizeof_fmt(selectedBytes)])

                    archiveBytes = backupUsage['archiveBytes']
                    printValues.extend([str(archiveBytes)])

                    printValues.extend([c42Lib.sizeof_fmt(archiveBytes)])

                    percentComplete = backupUsage['percentComplete']
                    printValues.extend([str(percentComplete)])

                    lastCompletedBackup = backupUsage['lastCompletedBackup']
                    printValues.extend([str(lastCompletedBackup)])

                    if 'history' in backupUsage:

                        backupHistory = backupUsage['history']

                        if backupHistory:

                            oldestDate = 9999999999999999999
                            # "20130801": 1909986568291,
                            oldestDateBytes = 0
                            newestDate = 0
                            # "20130830": 1932985363857
                            newestDateBytes = 0

                            for singleHistory in backupHistory:
                                # print key, value
                                # print oldestDate, int(key)
                                currDate = singleHistory['date'].replace(
                                    '-', '')

                                currarchiveBytes = singleHistory[
                                    'archiveBytes']

                                if (oldestDate > int(currDate)):
                                    oldestDate = int(currDate)
                                    oldestDateBytes = currarchiveBytes

                                # print newestDate, int(key)
                                if (newestDate <= int(currDate)):
                                    newestDate = int(currDate)
                                    newestDateBytes = currarchiveBytes

                            printValues.extend([str(oldestDate)])
                            printValues.extend([str(oldestDateBytes)])
                            printValues.extend(
                                [c42Lib.sizeof_fmt(oldestDateBytes)])

                            printValues.extend([str(newestDate)])
                            printValues.extend([str(newestDateBytes)])
                            printValues.extend(
                                [c42Lib.sizeof_fmt(newestDateBytes)])

                            pArchiveBytesDeltaMonth = newestDateBytes - oldestDateBytes
                            printValues.extend([str(pArchiveBytesDeltaMonth)])
                            printValues.extend(
                                [c42Lib.sizeof_fmt(pArchiveBytesDeltaMonth)])
                        # else:
                        # printDeviceEmptyBlock(8)
                    # else:
                    # printDeviceEmptyBlock(8)
                # else:
                # 	print("hi")
                # printDeviceEmptyBlock(19)

        # else:
        # print("bye")
        # printDeviceEmptyBlock(19)

        # print ', '.join(printValues)
        logging.info(str(printValues))
        csvDeviceFile.writerow(printValues)
def getUserReport():
	logging.info("User Export Action: startDate:" + cp_startDate + " | deltaTime: " +
		str(cp_deltaDate) + " | loggingLevel: " + cp_logLevel)
	csvUserFile = csv.writer(open("ExportAllUserDataCreateDateReport.csv", "wb+"))
	csvUserFile.writerow(csvUserHeaders)

	start_date_object = ""
	# end_date_object = ""

	start_date_object = datetime.datetime.strptime(cp_startDate, '%m/%d/%Y')
	# end_date_object = datetime.datetime.strptime(cp_endDate, '%m/%d/%Y')
	# print end_date_object

	emptyBlock = ""

	users = c42Lib.getAllUsers()
	# users = c42Lib.getUsers(1)
	for index, user in enumerate(users):
		# user = c42Lib.getUserById('6031')
		# user = c42Lib.getUserById('7403')

		printRow = []

		creationDate = ""
		if 'creationDate' in user:
			creationDate = user['creationDate']

		currDateObj = ""
		deltaTime = ""

		if creationDate is not None:
			currDateObj = datetime.datetime.strptime(str(creationDate)[:10], "%Y-%m-%d")
			deltaTime = start_date_object+relativedelta(months=+int(cp_deltaDate))


		# logging.info(str(currDateObj) + " delta: " + str(deltaTime))
		if deltaTime > currDateObj > start_date_object:

			pUserId = user['userId']
			# logging.info(str(pUserId))
			printRow.extend([str(pUserId)])

			pUserName = user['username']
			printRow.extend([pUserName.encode('utf-8')])

			pUserEmail = user['email']
			if pUserEmail is not None:
				printRow.extend([pUserEmail.encode('utf-8')])
			else:
				printRow.extend([emptyBlock])

			pUserOrgId = user['orgId']
			printRow.extend([str(pUserOrgId)])

			pUserOrgName = user['orgName']
			printRow.extend([pUserOrgName.encode('utf-8')])

			if 'computerCount' in user:
				pUserComputerCount = user['computerCount']
				printRow.extend([str(pUserComputerCount)])
			else:
				printRow.extend([emptyBlock])

			if 'creationDate' in user:
				pUserCreationDate = user['creationDate']
				printRow.extend([pUserCreationDate])

			if 'backupUsage' in user:

				userBackupUsage = user['backupUsage']

				if userBackupUsage:

					if 'archiveHistory' in userBackupUsage[0]:

						userBackupUsageArchiveHistory = userBackupUsage[0]['archiveHistory']

						if userBackupUsageArchiveHistory:

							oldestDate = 9999999999999999999
							# "20130801": 1909986568291,
							oldestDateBytes = 0
							newestDate = 0
						    # "20130830": 1932985363857
							newestDateBytes = 0

							for key, value in userBackupUsageArchiveHistory.items():
								# print key, value
								# print oldestDate, int(key)
								if (oldestDate > int(key)):
									oldestDate = int(key)
									oldestDateBytes = value

								# print newestDate, int(key)
								if (newestDate <= int(key)):
									newestDate = int(key)
									newestDateBytes = value

							printRow.extend([str(oldestDate)])
							printRow.extend([str(oldestDateBytes)])
							printRow.extend([c42Lib.sizeof_fmt(oldestDateBytes)])

							printRow.extend([str(newestDate)])
							printRow.extend([str(newestDateBytes)])
							printRow.extend([c42Lib.sizeof_fmt(newestDateBytes)])


							pArchiveBytesDeltaMonth = userBackupUsage[0]['archiveBytesDeltaMonth']
							printRow.extend([str(pArchiveBytesDeltaMonth)])
							printRow.extend([c42Lib.sizeof_fmt(pArchiveBytesDeltaMonth)])


							# pArchiveBytesDeltaMonthSanityCheck = newestDateBytes - oldestDateBytes
							# printRow.extend([str(pArchiveBytesDeltaMonthSanityCheck)])
							# printRow.extend([c42Lib.sizeof_fmt(pArchiveBytesDeltaMonthSanityCheck)])


			# 			else:
			# 				printUserEmptyBlock()

			# 		else:
			# 			printUserEmptyBlock()

			# else:
			# 	printUserEmptyBlock()

			logging.info(str(printRow))
			csvUserFile.writerow(printRow)
		else:
			logging.debug("nothing to report")
Exemple #5
0
def getUserReport():
	csvUserFile = csv.writer(open("allUserReport.csv", "wb+"))
	csvUserFile.writerow(csvUserHeaders)

	users = c42Lib.getAllUsers()
	for index, user in enumerate(users):
		# user = c42Lib.getUserById('6031')
		# user = c42Lib.getUserById('7403')

		printRow = []

		pUserId = user['userId']
		printRow.extend([str(pUserId)])

		pUserName = user['username']
		printRow.extend([pUserName.encode('utf-8')])

		pUserEmail = user['email']
		if pUserEmail is not None:
			printRow.extend([pUserEmail.encode('utf-8')])
		else:
			printRow.extend([emptyBlock])

		pUserOrgId = user['orgId']
		printRow.extend([str(pUserOrgId)])

		pUserOrgName = user['orgName']
		printRow.extend([pUserOrgName.encode('utf-8')])

		if 'computerCount' in user:
			pUserComputerCount = user['computerCount']
			printRow.extend([str(pUserComputerCount)])
		else:
			printRow.extend([emptyBlock])


		if 'backupUsage' in user:

			userBackupUsage = user['backupUsage']

			if userBackupUsage:

				if 'archiveHistory' in userBackupUsage[0]:

					userBackupUsageArchiveHistory = userBackupUsage[0]['archiveHistory']

					if userBackupUsageArchiveHistory:

						oldestDate = 9999999999999999999
						# "20130801": 1909986568291,
						oldestDateBytes = 0
						newestDate = 0
					    # "20130830": 1932985363857
						newestDateBytes = 0

						for key, value in userBackupUsageArchiveHistory.items():
							# print key, value
							# print oldestDate, int(key)
							if (oldestDate > int(key)):
								oldestDate = int(key)
								oldestDateBytes = value
							
							# print newestDate, int(key)
							if (newestDate <= int(key)):
								newestDate = int(key)
								newestDateBytes = value

						printRow.extend([str(oldestDate)])
						printRow.extend([str(oldestDateBytes)])
						printRow.extend([c42Lib.sizeof_fmt(oldestDateBytes)])

						printRow.extend([str(newestDate)])
						printRow.extend([str(newestDateBytes)])
						printRow.extend([c42Lib.sizeof_fmt(newestDateBytes)])


						pArchiveBytesDeltaMonth = userBackupUsage[0]['archiveBytesDeltaMonth']
						printRow.extend([str(pArchiveBytesDeltaMonth)])
						printRow.extend([c42Lib.sizeof_fmt(pArchiveBytesDeltaMonth)])


						# pArchiveBytesDeltaMonthSanityCheck = newestDateBytes - oldestDateBytes
						# printRow.extend([str(pArchiveBytesDeltaMonthSanityCheck)])
						# printRow.extend([c42Lib.sizeof_fmt(pArchiveBytesDeltaMonthSanityCheck)])

						
					else:
						printUserEmptyBlock()
				
				else:
					printUserEmptyBlock()

		else:
			printUserEmptyBlock()

		logging.info(str(printRow))
		csvUserFile.writerow(printRow)
def getDeviceReport():
	csvDeviceFile = csv.writer(open("allDeviceReport.csv", "wb+"))
	csvDeviceFile.writerow(csvDeviceHeader)

	users = c42Lib.getAllUsers()
	# get all the users to have in memory

	devices = c42Lib.getAllDevices()
	# devices = c42Lib.getDevices(1)

	for index, device in enumerate(devices):
		# device = c42Lib.getDeviceById(8637)
		printValues = []
		
		# computerId = loopDevice['computerId']

		# device = c42Lib.getDeviceById(computerId)

		userId = device['userId']
		printValues.extend([str(userId)])

		# Lookup User Info
		userInfo = findRecord(userId,users)

		logging.debug(userInfo)

		#Get User Name
		if userInfo:
			userName = userInfo['username']
		else:
			username = '******'
		printValues.extend([userName.encode('utf-8')])
		
		# print deviceObject
		computerId = device['computerId']
		printValues.extend([str(computerId)])

		computerName = device['name']
		printValues.extend([computerName.encode('utf-8')])

		computerType = device['type']
		printValues.extend([computerType.encode('utf-8')])

		osName = device['osName']
		printValues.extend([osName.encode('utf-8')])

		computerStatus = device['status']
		printValues.extend([computerStatus.encode('utf-8')])


		if 'backupUsage' in device:

			deviceObjectBackupUsage = device['backupUsage']

			for backupUsage in deviceObjectBackupUsage:

				if backupUsage['targetComputerId'] == destId:

					storePointId = backupUsage['storePointId']
					printValues.extend([str(storePointId)])

					storePointName = backupUsage['storePointName']
					printValues.extend([storePointName.encode('utf-8')])

					serverId = backupUsage['serverId']
					printValues.extend([str(serverId)])

					serverName = backupUsage['serverName']
					printValues.extend([serverName.encode('utf-8')])

					selectedFiles = backupUsage['selectedFiles']
					printValues.extend([str(selectedFiles)])

					selectedBytes = backupUsage['selectedBytes']
					printValues.extend([str(selectedBytes)])

					printValues.extend([c42Lib.sizeof_fmt(selectedBytes)])

					archiveBytes = backupUsage['archiveBytes']
					printValues.extend([str(archiveBytes)])

					printValues.extend([c42Lib.sizeof_fmt(archiveBytes)])

					percentComplete = backupUsage['percentComplete']
					printValues.extend([str(percentComplete)])

					lastCompletedBackup = backupUsage['lastCompletedBackup']
					printValues.extend([str(lastCompletedBackup)])


					if 'history' in backupUsage:
						
						backupHistory = backupUsage['history']

						if backupHistory:

							oldestDate = 9999999999999999999
							# "20130801": 1909986568291,
							oldestDateBytes = 0
							newestDate = 0
						    # "20130830": 1932985363857
							newestDateBytes = 0

							for singleHistory in backupHistory:
								# print key, value
								# print oldestDate, int(key)
								currDate = singleHistory['date'].replace('-','')

								currarchiveBytes = singleHistory['archiveBytes']

								if (oldestDate > int(currDate)):
									oldestDate = int(currDate)
									oldestDateBytes = currarchiveBytes
								
								# print newestDate, int(key)
								if (newestDate <= int(currDate)):
									newestDate = int(currDate)
									newestDateBytes = currarchiveBytes

							printValues.extend([str(oldestDate)])
							printValues.extend([str(oldestDateBytes)])
							printValues.extend([c42Lib.sizeof_fmt(oldestDateBytes)])

							printValues.extend([str(newestDate)])
							printValues.extend([str(newestDateBytes)])
							printValues.extend([c42Lib.sizeof_fmt(newestDateBytes)])

							pArchiveBytesDeltaMonth = newestDateBytes - oldestDateBytes
							printValues.extend([str(pArchiveBytesDeltaMonth)])
							printValues.extend([c42Lib.sizeof_fmt(pArchiveBytesDeltaMonth)])
						# else:
							# printDeviceEmptyBlock(8)
					# else:
						# printDeviceEmptyBlock(8)
				# else:
				# 	print("hi")
					# printDeviceEmptyBlock(19)

		# else:
			# print("bye")
			# printDeviceEmptyBlock(19)
	
		# print ', '.join(printValues)
		logging.info(str(printValues))
		csvDeviceFile.writerow(printValues)