def non_essential_count(base_json):
    #base_json = non_essential_json(base_path, cc_id)
    return {
        "total": get_occurrence_of_key(base_json, key="Touchstatus"),
        "essential": get_occurrence_of_value(base_json, value=True),
        "non-essential": get_occurrence_of_value(base_json, value=False)
    }
Esempio n. 2
0
 def test_sample_data4(self):
     result = get_occurrence_of_key(self.sample4, "checks")
     self.assertEqual(1, result)
     result = get_occurrence_of_value(self.sample4, "mziad")
     self.assertEqual(1, result)
     # Add one more value in key "monitoring_zones" and verify
     self.sample4["values"][0]["checks"][0]["monitoring_zones"].append("mziad")
     self.assertEqual(2, get_occurrence_of_value(self.sample4, "mziad"))
Esempio n. 3
0
def non_essential_count(base_json, filter="workspace"):
    #base_json = non_essential_json(base_path, cc_id)
    return {
        "folder": filter,
        "total": get_occurrence_of_key(base_json, key="Touchstatus"),
        "essential": get_occurrence_of_value(base_json, value=True),
        "non-essential": get_occurrence_of_value(base_json, value=False)
    }
 def test_sample_data4(self):
     result = get_occurrence_of_key(self.sample4, 'checks')
     self.assertEqual(1, result)
     result = get_occurrence_of_value(self.sample4, 'mziad')
     self.assertEqual(1, result)
     # Add one more value in key "monitoring_zones" and verify
     self.sample4['values'][0]['checks'][0]['monitoring_zones'].append(
         'mziad')
     self.assertEqual(2, get_occurrence_of_value(self.sample4, 'mziad'))
Esempio n. 5
0
def api(command):
    if command not in supported_commands:
        return 'Command %s not valid.\n' % command
    content = request.json
    def check(arg):
        if arg in content:
            payload[arg] = content[arg]
    def check_int(arg):
        if arg in content:
            payload[arg] = int(content[arg])
    payload = {
        'request_type': command
    }
    check('udid')
    check('currentpassword')            # For SetFirmwarePassword
    check('newpassword')                # For SetFirmwarePassword
    check('password')                   # For VerifyFirmwarePassword
    check('pin')                        # For DeviceLock
    check('product_key')                # For ScheduleOSUpdate
    check('install_action')             # For ScheduleOSUpdateScan
    check('force')                      # For ScheduleOSUpdateScan
    check('payload')	                # For InstallProfile
    check('identifier')                 # For RemoveProfile
    check('manifest_url')	            # For InstallEnterpriseApplication
    check('serial')                     # For InstallVPPApplication
    check_int('itunes_store_id')        # For InstallVPPApplication
    if 'InstallApplication' in command:
        options = {}
        options['purchase_method'] = int(1)
        payload['options'] = options
        # Get List of Licenses associated with Serial
        params = dict(
            sToken=settings.get('sToken'),
            serialNumber=content['serial']
        )
        resp = requests.get(url=settings.get('licensesurl'), json=params)
        data = resp.json()
        print(data)
        if get_occurrence_of_value(data, value=content['itunes_store_id']) == 0:
            # Assign this to this serial number
            print("Not assigned to this serial, doing so now")
            params = dict(
                sToken=settings.get('sToken'),
                associateSerialNumbers=[content['serial']],
                pricingParam="STDQ",
                adamIdStr=content['itunes_store_id']
                )
            print(requests.post(url=settings.get('manageurl'), json=params))
            print(params)
    requests.post(
        '{}/v1/commands'.format(settings.get('micromdm_url')),
        auth=('micromdm', settings.get('micromdm_key')),
        json=payload
    )
    return 'Issuing %s: Success! \n' % payload
Esempio n. 6
0
def find_all_occurence(d, value):
    results = []
    while get_occurrence_of_value(d, value=value) > 0:
        result = find_key(d, value)
        d = result[0]
        result = result[1]
        result.pop()
        #result.join('/')
        res = "/".join(result)
        #print res
        results.append(res)
        #print get_occurrence_of_value(d, value=value)
    return results
 def test_sample_data3(self):
     result = get_occurrence_of_key(self.sample3, 'total_number_of_cores')
     self.assertEqual(3, result)
     result = get_occurrence_of_value(self.sample3, '4')
     self.assertEqual(3, result)
 def test_sample_data2(self):
     result = get_occurrence_of_key(self.sample2, 'core_details')
     self.assertEqual(1, result)
     result = get_occurrence_of_value(self.sample2, '4')
     self.assertEqual(3, result)
 def test_sample_data1(self):
     result = get_occurrence_of_key(self.sample1, 'build_version')
     self.assertEqual(4, result)
     result = get_occurrence_of_value(self.sample1, '256 KB')
     self.assertEqual(2, result)
def get_count(color):
  return jsonify({ "count" : 
      str(get_occurrence_of_value(colors['color_data'], 
      value=color)) })