idx
int64
0
252k
question
stringlengths
48
5.28k
target
stringlengths
5
1.23k
245,900
def featureServers ( self ) : if self . urls == { } : return { } featuresUrls = self . urls [ 'urls' ] [ 'features' ] if 'https' in featuresUrls : res = featuresUrls [ 'https' ] elif 'http' in featuresUrls : res = featuresUrls [ 'http' ] else : return None services = [ ] for urlHost in res : if self . isPortal : services . append ( AGSAdministration ( url = '%s/admin' % urlHost , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) ) else : services . append ( Services ( url = 'https://%s/%s/ArcGIS/admin' % ( urlHost , self . portalId ) , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) ) return services
gets the hosting feature AGS Server
245,901
def update ( self , updatePortalParameters , clearEmptyFields = False ) : url = self . root + "/update" params = { "f" : "json" , "clearEmptyFields" : clearEmptyFields } if isinstance ( updatePortalParameters , parameters . PortalParameters ) : params . update ( updatePortalParameters . value ) elif isinstance ( updatePortalParameters , dict ) : for k , v in updatePortalParameters . items ( ) : params [ k ] = v else : raise AttributeError ( "updatePortalParameters must be of type parameter.PortalParameters" ) return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
The Update operation allows administrators only to update the organization information such as name description thumbnail and featured groups .
245,902
def updateUserRole ( self , user , role ) : url = self . _url + "/updateuserrole" params = { "f" : "json" , "user" : user , "role" : role } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
The Update User Role operation allows the administrator of an org anization to update the role of a user within a portal .
245,903
def isServiceNameAvailable ( self , name , serviceType ) : _allowedTypes = [ 'Feature Service' , "Map Service" ] url = self . _url + "/isServiceNameAvailable" params = { "f" : "json" , "name" : name , "type" : serviceType } return self . _get ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
Checks to see if a given service name and type are available for publishing a new service . true indicates that the name and type is not found in the organization s services and is available for publishing . false means the requested name and type are not available .
245,904
def servers ( self ) : url = "%s/servers" % self . root return Servers ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
gets the federated or registered servers for Portal
245,905
def users ( self , start = 1 , num = 10 , sortField = "fullName" , sortOrder = "asc" , role = None ) : users = [ ] url = self . _url + "/users" params = { "f" : "json" , "start" : start , "num" : num } if not role is None : params [ 'role' ] = role if not sortField is None : params [ 'sortField' ] = sortField if not sortOrder is None : params [ 'sortOrder' ] = sortOrder from . _community import Community res = self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) if "users" in res : if len ( res [ 'users' ] ) > 0 : parsed = urlparse . urlparse ( self . _url ) if parsed . netloc . lower ( ) . find ( 'arcgis.com' ) == - 1 : cURL = "%s://%s/%s/sharing/rest/community" % ( parsed . scheme , parsed . netloc , parsed . path [ 1 : ] . split ( '/' ) [ 0 ] ) else : cURL = "%s://%s/sharing/rest/community" % ( parsed . scheme , parsed . netloc ) com = Community ( url = cURL , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) for r in res [ 'users' ] : users . append ( com . users . user ( r [ "username" ] ) ) res [ 'users' ] = users return res
Lists all the members of the organization . The start and num paging parameters are supported .
245,906
def roles ( self ) : return Roles ( url = "%s/roles" % self . root , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
gets the roles class that allows admins to manage custom roles on portal
245,907
def resources ( self , start = 1 , num = 10 ) : url = self . _url + "/resources" params = { "f" : "json" , "start" : start , "num" : num } return self . _get ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
Resources lists all file resources for the organization . The start and num paging parameters are supported .
245,908
def addResource ( self , key , filePath , text ) : url = self . root + "/addresource" params = { "f" : "json" , "token" : self . _securityHandler . token , "key" : key , "text" : text } files = { } files [ 'file' ] = filePath res = self . _post ( url = url , param_dict = params , files = files , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) return res
The add resource operation allows the administrator to add a file resource for example the organization s logo or custom banner . The resource can be used by any member of the organization . File resources use storage space from your quota and are scanned for viruses .
245,909
def updateSecurityPolicy ( self , minLength = 8 , minUpper = None , minLower = None , minLetter = None , minDigit = None , minOther = None , expirationInDays = None , historySize = None ) : params = { "f" : "json" , "minLength" : minLength , "minUpper" : minUpper , "minLower" : minLower , "minLetter" : minLetter , "minDigit" : minDigit , "minOther" : minOther , "expirationInDays" : expirationInDays , "historySize" : historySize } url = "%s/securityPolicy/update" % self . root return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
updates the Portals security policy
245,910
def portalAdmin ( self ) : from . . manageportal import PortalAdministration return PortalAdministration ( admin_url = "https://%s/portaladmin" % self . portalHostname , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initalize = False )
gets a reference to a portal administration class
245,911
def addUser ( self , invitationList , subject , html ) : url = self . _url + "/invite" params = { "f" : "json" } if isinstance ( invitationList , parameters . InvitationList ) : params [ 'invitationList' ] = invitationList . value ( ) params [ 'html' ] = html params [ 'subject' ] = subject return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
adds a user without sending an invitation email
245,912
def inviteByEmail ( self , emails , subject , text , html , role = "org_user" , mustApprove = True , expiration = 1440 ) : url = self . root + "/inviteByEmail" params = { "f" : "json" , "emails" : emails , "subject" : subject , "text" : text , "html" : html , "role" : role , "mustApprove" : mustApprove , "expiration" : expiration } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
Invites a user or users to a site .
245,913
def usage ( self , startTime , endTime , vars = None , period = None , groupby = None , name = None , stype = None , etype = None , appId = None , deviceId = None , username = None , appOrgId = None , userOrgId = None , hostOrgId = None ) : url = self . root + "/usage" startTime = str ( int ( local_time_to_online ( dt = startTime ) ) ) endTime = str ( int ( local_time_to_online ( dt = endTime ) ) ) params = { 'f' : 'json' , 'startTime' : startTime , 'endTime' : endTime , 'vars' : vars , 'period' : period , 'groupby' : groupby , 'name' : name , 'stype' : stype , 'etype' : etype , 'appId' : appId , 'deviceId' : deviceId , 'username' : username , 'appOrgId' : appOrgId , 'userOrgId' : userOrgId , 'hostOrgId' : hostOrgId , } params = { key : item for key , item in params . items ( ) if item is not None } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
returns the usage statistics value
245,914
def servers ( self ) : self . __init ( ) items = [ ] for k , v in self . _json_dict . items ( ) : if k == "servers" : for s in v : if 'id' in s : url = "%s/%s" % ( self . root , s [ 'id' ] ) items . append ( self . Server ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) ) del k , v return items
gets all the server resources
245,915
def deleteRole ( self , roleID ) : url = self . _url + "/%s/delete" % roleID params = { "f" : "json" } return self . _post ( url = url , param_dict = params , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
deletes a role by ID
245,916
def updateRole ( self , roleID , name , description ) : params = { "name" : name , "description" : description , "f" : "json" } url = self . _url + "/%s/update" return self . _post ( url = url , param_dict = params , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
allows for the role name or description to be modified
245,917
def findRoleID ( self , name ) : for r in self : if r [ 'name' ] . lower ( ) == name . lower ( ) : return r [ 'id' ] del r return None
searches the roles by name and returns the role s ID
245,918
def get_config_value ( config_file , section , variable ) : try : parser = ConfigParser . SafeConfigParser ( ) parser . read ( config_file ) return parser . get ( section , variable ) except : return None
extracts a config file value
245,919
def users ( self ) : return Users ( url = "%s/users" % self . root , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
Provides access to all user resources
245,920
def getItem ( self , itemId ) : url = "%s/items/%s" % ( self . root , itemId ) return Item ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
gets the refernce to the Items class which manages content on a given AGOL or Portal site .
245,921
def FeatureContent ( self ) : return FeatureContent ( url = "%s/%s" % ( self . root , "features" ) , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
Feature Content class id the parent resource for feature operations such as Analyze and Generate .
245,922
def user ( self , username = None ) : if username is None : username = self . __getUsername ( ) url = "%s/%s" % ( self . root , username ) return User ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initalize = True )
gets the user s content . If None is passed the current user is used .
245,923
def saveThumbnail ( self , fileName , filePath ) : if self . _thumbnail is None : self . __init ( ) param_dict = { } if self . _thumbnail is not None : imgUrl = self . root + "/info/" + self . _thumbnail onlineFileName , file_ext = splitext ( self . _thumbnail ) fileNameSafe = "" . join ( x for x in fileName if x . isalnum ( ) ) + file_ext result = self . _get ( url = imgUrl , param_dict = param_dict , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , out_folder = filePath , file_name = fileNameSafe ) return result else : return None
URL to the thumbnail used for the item
245,924
def userItem ( self ) : if self . ownerFolder is not None : url = "%s/users/%s/%s/items/%s" % ( self . root . split ( '/items/' ) [ 0 ] , self . owner , self . ownerFolder , self . id ) else : url = "%s/users/%s/items/%s" % ( self . root . split ( '/items/' ) [ 0 ] , self . owner , self . id ) return UserItem ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
returns a reference to the UserItem class
245,925
def addRating ( self , rating = 5.0 ) : if rating > 5.0 : rating = 5.0 elif rating < 1.0 : rating = 1.0 url = "%s/addRating" % self . root params = { "f" : "json" , "rating" : "%s" % rating } return self . _post ( url , params , proxy_port = self . _proxy_port , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url )
Adds a rating to an item between 1 . 0 and 5 . 0
245,926
def addComment ( self , comment ) : url = "%s/addComment" % self . root params = { "f" : "json" , "comment" : comment } return self . _post ( url , params , proxy_port = self . _proxy_port , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url )
adds a comment to a given item . Must be authenticated
245,927
def itemComment ( self , commentId ) : url = "%s/comments/%s" % ( self . root , commentId ) params = { "f" : "json" } return self . _get ( url , params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url )
returns details of a single comment
245,928
def itemComments ( self ) : url = "%s/comments/" % self . root params = { "f" : "json" } return self . _get ( url , params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url )
returns all comments for a given item
245,929
def deleteComment ( self , commentId ) : url = "%s/comments/%s/delete" % ( self . root , commentId ) params = { "f" : "json" , } return self . _post ( url , params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url )
removes a comment from an Item
245,930
def packageInfo ( self ) : url = "%s/item.pkinfo" % self . root params = { 'f' : 'json' } result = self . _get ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , out_folder = tempfile . gettempdir ( ) ) return result
gets the item s package information file
245,931
def item ( self ) : url = self . _contentURL return Item ( url = self . _contentURL , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initalize = True )
returns the Item class of an Item
245,932
def reassignItem ( self , targetUsername , targetFoldername ) : params = { "f" : "json" , "targetUsername" : targetUsername , "targetFoldername" : targetFoldername } url = "%s/reassign" % self . root return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
The Reassign Item operation allows the administrator of an organization to reassign a member s item to another member of the organization .
245,933
def updateItem ( self , itemParameters , clearEmptyFields = False , data = None , metadata = None , text = None , serviceUrl = None , multipart = False ) : thumbnail = None largeThumbnail = None files = { } params = { "f" : "json" , } if clearEmptyFields : params [ "clearEmptyFields" ] = clearEmptyFields if serviceUrl is not None : params [ 'url' ] = serviceUrl if text is not None : params [ 'text' ] = text if isinstance ( itemParameters , ItemParameter ) == False : raise AttributeError ( "itemParameters must be of type parameter.ItemParameter" ) keys_to_delete = [ 'id' , 'owner' , 'size' , 'numComments' , 'numRatings' , 'avgRating' , 'numViews' , 'overwrite' ] dictItem = itemParameters . value for key in keys_to_delete : if key in dictItem : del dictItem [ key ] for key in dictItem : if key == "thumbnail" : files [ 'thumbnail' ] = dictItem [ 'thumbnail' ] elif key == "largeThumbnail" : files [ 'largeThumbnail' ] = dictItem [ 'largeThumbnail' ] elif key == "metadata" : metadata = dictItem [ 'metadata' ] if os . path . basename ( metadata ) != 'metadata.xml' : tempxmlfile = os . path . join ( tempfile . gettempdir ( ) , "metadata.xml" ) if os . path . isfile ( tempxmlfile ) == True : os . remove ( tempxmlfile ) import shutil shutil . copy ( metadata , tempxmlfile ) metadata = tempxmlfile files [ 'metadata' ] = dictItem [ 'metadata' ] else : params [ key ] = dictItem [ key ] if data is not None : files [ 'file' ] = data if metadata and os . path . isfile ( metadata ) : files [ 'metadata' ] = metadata url = "%s/update" % self . root if multipart : itemID = self . id params [ 'multipart' ] = True params [ 'fileName' ] = os . path . basename ( data ) res = self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) itemPartJSON = self . addByPart ( filePath = data ) res = self . commit ( wait = True , additionalParams = { 'type' : self . type } ) else : res = self . _post ( url = url , param_dict = params , files = files , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , force_form_post = True ) self . __init ( ) return self
updates an item s properties using the ItemParameter class .
245,934
def status ( self , jobId = None , jobType = None ) : params = { "f" : "json" } if jobType is not None : params [ 'jobType' ] = jobType if jobId is not None : params [ "jobId" ] = jobId url = "%s/status" % self . root return self . _get ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url )
Inquire about status when publishing an item adding an item in async mode or adding with a multipart upload . Partial is available for Add Item Multipart when only a part is uploaded and the item is not committed .
245,935
def commit ( self , wait = False , additionalParams = { } ) : url = "%s/commit" % self . root params = { "f" : "json" , } for key , value in additionalParams . items ( ) : params [ key ] = value if wait == True : res = self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) res = self . status ( ) import time while res [ 'status' ] . lower ( ) in [ "partial" , "processing" ] : time . sleep ( 2 ) res = self . status ( ) return res else : return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url )
Commit is called once all parts are uploaded during a multipart Add Item or Update Item operation . The parts are combined into a file and the original file is overwritten during an Update Item operation . This is an asynchronous call and returns immediately . Status can be used to check the status of the operation until it is completed .
245,936
def folders ( self ) : if self . _folders is None : self . __init ( ) if self . _folders is not None and isinstance ( self . _folders , list ) : if len ( self . _folders ) == 0 : self . _loadFolders ( ) return self . _folders
gets the property value for folders
245,937
def items ( self ) : self . __init ( ) items = [ ] for item in self . _items : items . append ( UserItem ( url = "%s/items/%s" % ( self . location , item [ 'id' ] ) , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initalize = True ) ) return items
gets the property value for items
245,938
def addRelationship ( self , originItemId , destinationItemId , relationshipType ) : url = "%s/addRelationship" % self . root params = { "originItemId" : originItemId , "destinationItemId" : destinationItemId , "relationshipType" : relationshipType , "f" : "json" } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url )
Adds a relationship of a certain type between two items .
245,939
def createService ( self , createServiceParameter , description = None , tags = "Feature Service" , snippet = None ) : url = "%s/createService" % self . location val = createServiceParameter . value params = { "f" : "json" , "outputType" : "featureService" , "createParameters" : json . dumps ( val ) , "tags" : tags } if snippet is not None : params [ 'snippet' ] = snippet if description is not None : params [ 'description' ] = description res = self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) if 'id' in res or 'serviceItemId' in res : if 'id' in res : url = "%s/items/%s" % ( self . location , res [ 'id' ] ) else : url = "%s/items/%s" % ( self . location , res [ 'serviceItemId' ] ) return UserItem ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) return res
The Create Service operation allows users to create a hosted feature service . You can use the API to create an empty hosted feaure service from feature service metadata JSON .
245,940
def shareItems ( self , items , groups = "" , everyone = False , org = False ) : url = "%s/shareItems" % self . root params = { "f" : "json" , "items" : items , "everyone" : everyone , "org" : org , "groups" : groups } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url )
Shares a batch of items with the specified list of groups . Users can only share items with groups to which they belong . This operation also allows a user to share items with everyone in which case the items are publicly accessible or with everyone in their organization .
245,941
def createFolder ( self , name ) : url = "%s/createFolder" % self . root params = { "f" : "json" , "title" : name } self . _folders = None return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url )
Creates a folder in which items can be placed . Folders are only visible to a user and solely used for organizing content within that user s content space .
245,942
def analyze ( self , itemId = None , filePath = None , text = None , fileType = "csv" , analyzeParameters = None ) : files = [ ] url = self . _url + "/analyze" params = { "f" : "json" } fileType = "csv" params [ "fileType" ] = fileType if analyzeParameters is not None and isinstance ( analyzeParameters , AnalyzeParameters ) : params [ 'analyzeParameters' ] = analyzeParameters . value if not ( filePath is None ) and os . path . isfile ( filePath ) : params [ 'text' ] = open ( filePath , 'rb' ) . read ( ) return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) elif itemId is not None : params [ "fileType" ] = fileType params [ 'itemId' ] = itemId return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) else : raise AttributeError ( "either an Item ID or a file path must be given." )
The Analyze call helps a client analyze a CSV file prior to publishing or generating features using the Publish or Generate operation respectively . Analyze returns information about the file including the fields present as well as sample records . Analyze attempts to detect the presence of location fields that may be present as either X Y fields or address fields . Analyze packages its result so that publishParameters within the JSON response contains information that can be passed back to the server in a subsequent call to Publish or Generate . The publishParameters subobject contains properties that describe the resulting layer after publishing including its fields the desired renderer and so on . Analyze will suggest defaults for the renderer . In a typical workflow the client will present portions of the Analyze results to the user for editing before making the call to Publish or Generate . If the file to be analyzed currently exists in the portal as an item callers can pass in its itemId . Callers can also directly post the file . In this case the request must be a multipart post request pursuant to IETF RFC1867 . The third option for text files is to pass the text in as the value of the text parameter .
245,943
def __assembleURL ( self , url , groupId ) : from . . packages . six . moves . urllib_parse import urlparse parsed = urlparse ( url ) communityURL = "%s://%s%s/sharing/rest/community/groups/%s" % ( parsed . scheme , parsed . netloc , parsed . path . lower ( ) . split ( '/sharing/rest/' ) [ 0 ] , groupId ) return communityURL
private function that assembles the URL for the community . Group class
245,944
def group ( self ) : split_count = self . _url . lower ( ) . find ( "/content/" ) len_count = len ( '/content/' ) gURL = self . _url [ : self . _url . lower ( ) . find ( "/content/" ) ] + "/community/" + self . _url [ split_count + len_count : ] return CommunityGroup ( url = gURL , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
returns the community . Group class for the current group
245,945
def addUniqueValue ( self , value , label , description , symbol ) : if self . _uniqueValueInfos is None : self . _uniqueValueInfos = [ ] self . _uniqueValueInfos . append ( { "value" : value , "label" : label , "description" : description , "symbol" : symbol } )
adds a unique value to the renderer
245,946
def removeUniqueValue ( self , value ) : for v in self . _uniqueValueInfos : if v [ 'value' ] == value : self . _uniqueValueInfos . remove ( v ) return True del v return False
removes a unique value in unique Value Info
245,947
def addClassBreak ( self , classMinValue , classMaxValue , label , description , symbol ) : if self . _classBreakInfos is None : self . _classBreakInfos = [ ] self . _classBreakInfos . append ( { "classMinValue" : classMinValue , "classMaxValue" : classMaxValue , "label" : label , "description" : description , "symbol" : symbol } )
adds a classification break value to the renderer
245,948
def removeClassBreak ( self , label ) : for v in self . _classBreakInfos : if v [ 'label' ] == label : self . _classBreakInfos . remove ( v ) return True del v return False
removes a classification break value to the renderer
245,949
def downloadThumbnail ( self , outPath ) : url = self . _url + "/info/thumbnail" params = { } return self . _get ( url = url , out_folder = outPath , file_name = None , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
downloads the items s thumbnail
245,950
def __init ( self ) : params = { "f" : "json" } json_dict = self . _get ( self . _url , params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) self . _json = json . dumps ( json_dict ) self . _json_dict = json_dict attributes = [ attr for attr in dir ( self ) if not attr . startswith ( '__' ) and not attr . startswith ( '_' ) ] for k , v in json_dict . items ( ) : if k == "tables" : self . _tables = [ ] for tbl in v : url = self . _url + "/%s" % tbl [ 'id' ] self . _tables . append ( TableLayer ( url , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) ) elif k == "layers" : self . _layers = [ ] for lyr in v : url = self . _url + "/%s" % lyr [ 'id' ] layer_type = self . _getLayerType ( url ) if layer_type == "Feature Layer" : self . _layers . append ( FeatureLayer ( url , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) ) elif layer_type == "Raster Layer" : self . _layers . append ( RasterLayer ( url , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) ) elif layer_type == "Group Layer" : self . _layers . append ( GroupLayer ( url , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) ) elif layer_type == "Schematics Layer" : self . _layers . append ( SchematicsLayer ( url , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) ) else : print ( 'Type %s is not implemented' % layer_type ) elif k in attributes : setattr ( self , "_" + k , json_dict [ k ] ) else : print ( k , " is not implemented for mapservice." )
populates all the properties for the map service
245,951
def getExtensions ( self ) : extensions = [ ] if isinstance ( self . supportedExtensions , list ) : for ext in self . supportedExtensions : extensionURL = self . _url + "/exts/%s" % ext if ext == "SchematicsServer" : extensions . append ( SchematicsService ( url = extensionURL , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) ) return extensions else : extensionURL = self . _url + "/exts/%s" % self . supportedExtensions if self . supportedExtensions == "SchematicsServer" : extensions . append ( SchematicsService ( url = extensionURL , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) ) return extensions
returns objects for all map service extensions
245,952
def allLayers ( self ) : url = self . _url + "/layers" params = { "f" : "json" } res = self . _get ( url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) return_dict = { "layers" : [ ] , "tables" : [ ] } for k , v in res . items ( ) : if k == "layers" : for val in v : return_dict [ 'layers' ] . append ( FeatureLayer ( url = self . _url + "/%s" % val [ 'id' ] , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) ) elif k == "tables" : for val in v : return_dict [ 'tables' ] . append ( TableLayer ( url = self . _url + "/%s" % val [ 'id' ] , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) ) del k , v return return_dict
returns all layers for the service
245,953
def find ( self , searchText , layers , contains = True , searchFields = "" , sr = "" , layerDefs = "" , returnGeometry = True , maxAllowableOffset = "" , geometryPrecision = "" , dynamicLayers = "" , returnZ = False , returnM = False , gdbVersion = "" ) : url = self . _url + "/find" params = { "f" : "json" , "searchText" : searchText , "contains" : self . _convert_boolean ( contains ) , "searchFields" : searchFields , "sr" : sr , "layerDefs" : layerDefs , "returnGeometry" : self . _convert_boolean ( returnGeometry ) , "maxAllowableOffset" : maxAllowableOffset , "geometryPrecision" : geometryPrecision , "dynamicLayers" : dynamicLayers , "returnZ" : self . _convert_boolean ( returnZ ) , "returnM" : self . _convert_boolean ( returnM ) , "gdbVersion" : gdbVersion , "layers" : layers } res = self . _get ( url , params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) qResults = [ ] for r in res [ 'results' ] : qResults . append ( Feature ( r ) ) return qResults
performs the map service find operation
245,954
def getFeatureDynamicLayer ( self , oid , dynamicLayer , returnZ = False , returnM = False ) : url = self . _url + "/dynamicLayer/%s" % oid params = { "f" : "json" , "returnZ" : returnZ , "returnM" : returnM , "layer" : { "id" : 101 , "source" : dynamicLayer . asDictionary } } return Feature ( json_string = self . _get ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) )
The feature resource represents a single feature in a dynamic layer in a map service
245,955
def identify ( self , geometry , mapExtent , imageDisplay , tolerance , geometryType = "esriGeometryPoint" , sr = None , layerDefs = None , time = None , layerTimeOptions = None , layers = "top" , returnGeometry = True , maxAllowableOffset = None , geometryPrecision = None , dynamicLayers = None , returnZ = False , returnM = False , gdbVersion = None ) : params = { 'f' : 'json' , 'geometry' : geometry , 'geometryType' : geometryType , 'tolerance' : tolerance , 'mapExtent' : mapExtent , 'imageDisplay' : imageDisplay } if layerDefs is not None : params [ 'layerDefs' ] = layerDefs if layers is not None : params [ 'layers' ] = layers if sr is not None : params [ 'sr' ] = sr if time is not None : params [ 'time' ] = time if layerTimeOptions is not None : params [ 'layerTimeOptions' ] = layerTimeOptions if maxAllowableOffset is not None : params [ 'maxAllowableOffset' ] = maxAllowableOffset if geometryPrecision is not None : params [ 'geometryPrecision' ] = geometryPrecision if dynamicLayers is not None : params [ 'dynamicLayers' ] = dynamicLayers if gdbVersion is not None : params [ 'gdbVersion' ] = gdbVersion identifyURL = self . _url + "/identify" return self . _get ( url = identifyURL , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
The identify operation is performed on a map service resource to discover features at a geographic location . The result of this operation is an identify results resource . Each identified result includes its name layer ID layer name geometry and geometry type and other attributes of that result as name - value pairs .
245,956
def fromJSON ( value ) : if isinstance ( value , str ) : value = json . loads ( value ) elif isinstance ( value , dict ) : pass else : raise AttributeError ( "Invalid input" ) return Extension ( typeName = value [ 'typeName' ] , capabilities = value [ 'capabilities' ] , enabled = value [ 'enabled' ] == "true" , maxUploadFileSize = value [ 'maxUploadFileSize' ] , allowedUploadFileType = value [ 'allowedUploadFileTypes' ] , properties = value [ 'properties' ] )
returns the object from json string or dictionary
245,957
def asList ( self ) : return [ self . _red , self . _green , self . _blue , self . _alpha ]
returns the value as the list object
245,958
def color ( self , value ) : if isinstance ( value , ( list , Color ) ) : if value is list : self . _color = value else : self . _color = value . asList
sets the color
245,959
def outlineColor ( self , value ) : if isinstance ( value , ( list , Color ) ) : if value is list : self . _outlineColor = value else : self . _outlineColor = value . asList
sets the outline color
245,960
def outline ( self , value ) : if isinstance ( value , SimpleLineSymbol ) : self . _outline = value . asDictionary
sets the outline
245,961
def base64ToImage ( imgData , out_path , out_file ) : fh = open ( os . path . join ( out_path , out_file ) , "wb" ) fh . write ( imgData . decode ( 'base64' ) ) fh . close ( ) del fh return os . path . join ( out_path , out_file )
converts a base64 string to a file
245,962
def find ( self , text , magicKey = None , sourceCountry = None , bbox = None , location = None , distance = 3218.69 , outSR = 102100 , category = None , outFields = "*" , maxLocations = 20 , forStorage = False ) : if isinstance ( self . _securityHandler , ( AGOLTokenSecurityHandler , OAuthSecurityHandler ) ) : url = self . _url + "/find" params = { "f" : "json" , "text" : text , } if not magicKey is None : params [ 'magicKey' ] = magicKey if not sourceCountry is None : params [ 'sourceCountry' ] = sourceCountry if not bbox is None : params [ 'bbox' ] = bbox if not location is None : if isinstance ( location , Point ) : params [ 'location' ] = location . asDictionary if isinstance ( location , list ) : params [ 'location' ] = "%s,%s" % ( location [ 0 ] , location [ 1 ] ) if not distance is None : params [ 'distance' ] = distance if not outSR is None : params [ 'outSR' ] = outSR if not category is None : params [ 'category' ] = category if outFields is None : params [ 'outFields' ] = "*" else : params [ 'outFields' ] = outFields if not maxLocations is None : params [ 'maxLocations' ] = maxLocations if not forStorage is None : params [ 'forStorage' ] = forStorage return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) else : raise Exception ( "This function works on the ArcGIS Online World Geocoder" )
The find operation geocodes one location per request ; the input address is specified in a single parameter .
245,963
def geocodeAddresses ( self , addresses , outSR = 4326 , sourceCountry = None , category = None ) : params = { "f" : "json" } url = self . _url + "/geocodeAddresses" params [ 'outSR' ] = outSR params [ 'sourceCountry' ] = sourceCountry params [ 'category' ] = category params [ 'addresses' ] = addresses return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
The geocodeAddresses operation is performed on a Geocode Service resource . The result of this operation is a resource representing the list of geocoded addresses . This resource provides information about the addresses including the address location score and other geocode service - specific attributes . You can provide arguments to the geocodeAddresses operation as query parameters defined in the following parameters table .
245,964
def __init ( self ) : params = { "f" : "json" , } json_dict = self . _get ( self . _url , params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) self . _json_dict = json_dict self . _json = json . dumps ( self . _json_dict ) attributes = [ attr for attr in dir ( self ) if not attr . startswith ( '__' ) and not attr . startswith ( '_' ) ] for k , v in json_dict . items ( ) : if k in attributes : if k == "routeLayers" and json_dict [ k ] : self . _routeLayers = [ ] for rl in v : self . _routeLayers . append ( RouteNetworkLayer ( url = self . _url + "/%s" % rl , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initialize = False ) ) elif k == "serviceAreaLayers" and json_dict [ k ] : self . _serviceAreaLayers = [ ] for sal in v : self . _serviceAreaLayers . append ( ServiceAreaNetworkLayer ( url = self . _url + "/%s" % sal , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initialize = False ) ) elif k == "closestFacilityLayers" and json_dict [ k ] : self . _closestFacilityLayers = [ ] for cf in v : self . _closestFacilityLayers . append ( ClosestFacilityNetworkLayer ( url = self . _url + "/%s" % cf , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initialize = False ) ) else : setattr ( self , "_" + k , v ) else : print ( "attribute %s is not implemented." % k )
initializes the properties
245,965
def __init ( self ) : params = { "f" : "json" } json_dict = self . _get ( url = self . _url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) attributes = [ attr for attr in dir ( self ) if not attr . startswith ( '__' ) and not attr . startswith ( '_' ) ] for k , v in json_dict . items ( ) : if k in attributes : setattr ( self , "_" + k , json_dict [ k ] ) else : print ( k , " - attribute not implemented in RouteNetworkLayer." ) del k , v
initializes all the properties
245,966
def download ( self , itemID , savePath ) : if os . path . isdir ( savePath ) == False : os . makedirs ( savePath ) url = self . _url + "/%s/download" % itemID params = { } if len ( params . keys ( ) ) : url = url + "?%s" % urlencode ( params ) return self . _get ( url = url , param_dict = params , out_folder = savePath , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
downloads an item to local disk
245,967
def reports ( self ) : if self . _metrics is None : self . __init ( ) self . _reports = [ ] for r in self . _metrics : url = self . _url + "/%s" % six . moves . urllib . parse . quote_plus ( r [ 'reportname' ] ) self . _reports . append ( UsageReport ( url = url , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initialize = True ) ) del url return self . _reports
returns a list of reports on the server
245,968
def editUsageReportSettings ( self , samplingInterval , enabled = True , maxHistory = 0 ) : params = { "f" : "json" , "maxHistory" : maxHistory , "enabled" : enabled , "samplingInterval" : samplingInterval } url = self . _url + "/settings/edit" return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
The usage reports settings are applied to the entire site . A POST request updates the usage reports settings .
245,969
def createUsageReport ( self , reportname , queries , metadata , since = "LAST_DAY" , fromValue = None , toValue = None , aggregationInterval = None ) : url = self . _url + "/add" params = { "f" : "json" , "usagereport" : { "reportname" : reportname , "since" : since , "metadata" : metadata } } if isinstance ( queries , dict ) : params [ "usagereport" ] [ "queries" ] = [ queries ] elif isinstance ( queries , list ) : params [ "usagereport" ] [ "queries" ] = queries if aggregationInterval is not None : params [ "usagereport" ] [ 'aggregationInterval' ] = aggregationInterval if since . lower ( ) == "custom" : params [ "usagereport" ] [ 'to' ] = toValue params [ "usagereport" ] [ 'from' ] = fromValue res = self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) self . __init ( ) return res
Creates a new usage report . A usage report is created by submitting a JSON representation of the usage report to this operation .
245,970
def edit ( self ) : usagereport_dict = { "reportname" : self . reportname , "queries" : self . _queries , "since" : self . since , "metadata" : self . _metadata , "to" : self . _to , "from" : self . _from , "aggregationInterval" : self . _aggregationInterval } params = { "f" : "json" , "usagereport" : json . dumps ( usagereport_dict ) } url = self . _url + "/edit" return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
Edits the usage report . To edit a usage report you need to submit the complete JSON representation of the usage report which includes updates to the usage report properties . The name of the report cannot be changed when editing the usage report .
245,971
def __init ( self ) : params = { "f" : "json" , } json_dict = self . _get ( self . _url , params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) self . _json_dict = json_dict self . _json = json . dumps ( self . _json_dict ) attributes = [ attr for attr in dir ( self ) if not attr . startswith ( '__' ) and not attr . startswith ( '_' ) ] for k , v in json_dict . items ( ) : if k in attributes : if k == "versions" and json_dict [ k ] : self . _versions = [ ] for version in v : self . _versions . append ( Version ( url = self . _url + "/versions/%s" % version , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initialize = False ) ) elif k == "replicas" and json_dict [ k ] : self . _replicas = [ ] for version in v : self . _replicas . append ( Replica ( url = self . _url + "/replicas/%s" % version , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , initialize = False ) ) else : setattr ( self , "_" + k , v ) else : print ( k , " - attribute not implemented for GeoData Service" )
inializes the properties
245,972
def replicasResource ( self ) : if self . _replicasResource is None : self . _replicasResource = { } for replica in self . replicas : self . _replicasResource [ "replicaName" ] = replica . name self . _replicasResource [ "replicaID" ] = replica . guid return self . _replicasResource
returns a list of replices
245,973
def services ( self ) : self . _services = [ ] params = { "f" : "json" } if not self . _url . endswith ( '/services' ) : uURL = self . _url + "/services" else : uURL = self . _url res = self . _get ( url = uURL , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) for k , v in res . items ( ) : if k == "foldersDetail" : for item in v : if 'isDefault' in item and item [ 'isDefault' ] == False : fURL = self . _url + "/services/" + item [ 'folderName' ] resFolder = self . _get ( url = fURL , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) for k1 , v1 in resFolder . items ( ) : if k1 == "services" : self . _checkservice ( k1 , v1 , fURL ) elif k == "services" : self . _checkservice ( k , v , uURL ) return self . _services
returns all the service objects in the admin service s page
245,974
def refresh ( self , serviceDefinition = True ) : url = self . _url + "/MapServer/refresh" params = { "f" : "json" , "serviceDefinition" : serviceDefinition } res = self . _post ( url = self . _url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) self . __init ( ) return res
The refresh operation refreshes a service which clears the web server cache for the service .
245,975
def editTileService ( self , serviceDefinition = None , minScale = None , maxScale = None , sourceItemId = None , exportTilesAllowed = False , maxExportTileCount = 100000 ) : params = { "f" : "json" , } if not serviceDefinition is None : params [ "serviceDefinition" ] = serviceDefinition if not minScale is None : params [ 'minScale' ] = float ( minScale ) if not maxScale is None : params [ 'maxScale' ] = float ( maxScale ) if not sourceItemId is None : params [ "sourceItemId" ] = sourceItemId if not exportTilesAllowed is None : params [ "exportTilesAllowed" ] = exportTilesAllowed if not maxExportTileCount is None : params [ "maxExportTileCount" ] = int ( maxExportTileCount ) url = self . _url + "/edit" return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _securityHandler . proxy_url , proxy_port = self . _securityHandler . proxy_port )
This post operation updates a Tile Service s properties
245,976
def refresh ( self ) : params = { "f" : "json" } uURL = self . _url + "/refresh" res = self . _get ( url = uURL , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) self . __init ( ) return res
refreshes a service
245,977
def addToDefinition ( self , json_dict ) : params = { "f" : "json" , "addToDefinition" : json . dumps ( json_dict ) , "async" : False } uURL = self . _url + "/addToDefinition" res = self . _post ( url = uURL , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) self . refresh ( ) return res
The addToDefinition operation supports adding a definition property to a hosted feature service . The result of this operation is a response indicating success or failure with error code and description .
245,978
def updateDefinition ( self , json_dict ) : definition = None if json_dict is not None : if isinstance ( json_dict , collections . OrderedDict ) == True : definition = json_dict else : definition = collections . OrderedDict ( ) if 'hasStaticData' in json_dict : definition [ 'hasStaticData' ] = json_dict [ 'hasStaticData' ] if 'allowGeometryUpdates' in json_dict : definition [ 'allowGeometryUpdates' ] = json_dict [ 'allowGeometryUpdates' ] if 'capabilities' in json_dict : definition [ 'capabilities' ] = json_dict [ 'capabilities' ] if 'editorTrackingInfo' in json_dict : definition [ 'editorTrackingInfo' ] = collections . OrderedDict ( ) if 'enableEditorTracking' in json_dict [ 'editorTrackingInfo' ] : definition [ 'editorTrackingInfo' ] [ 'enableEditorTracking' ] = json_dict [ 'editorTrackingInfo' ] [ 'enableEditorTracking' ] if 'enableOwnershipAccessControl' in json_dict [ 'editorTrackingInfo' ] : definition [ 'editorTrackingInfo' ] [ 'enableOwnershipAccessControl' ] = json_dict [ 'editorTrackingInfo' ] [ 'enableOwnershipAccessControl' ] if 'allowOthersToUpdate' in json_dict [ 'editorTrackingInfo' ] : definition [ 'editorTrackingInfo' ] [ 'allowOthersToUpdate' ] = json_dict [ 'editorTrackingInfo' ] [ 'allowOthersToUpdate' ] if 'allowOthersToDelete' in json_dict [ 'editorTrackingInfo' ] : definition [ 'editorTrackingInfo' ] [ 'allowOthersToDelete' ] = json_dict [ 'editorTrackingInfo' ] [ 'allowOthersToDelete' ] if 'allowOthersToQuery' in json_dict [ 'editorTrackingInfo' ] : definition [ 'editorTrackingInfo' ] [ 'allowOthersToQuery' ] = json_dict [ 'editorTrackingInfo' ] [ 'allowOthersToQuery' ] if isinstance ( json_dict [ 'editorTrackingInfo' ] , dict ) : for k , v in json_dict [ 'editorTrackingInfo' ] . items ( ) : if k not in definition [ 'editorTrackingInfo' ] : definition [ 'editorTrackingInfo' ] [ k ] = v if isinstance ( json_dict , dict ) : for k , v in json_dict . items ( ) : if k not in definition : definition [ k ] = v params = { "f" : "json" , "updateDefinition" : json . dumps ( obj = definition , separators = ( ',' , ':' ) ) , "async" : False } uURL = self . _url + "/updateDefinition" res = self . _post ( url = uURL , param_dict = params , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) self . refresh ( ) return res
The updateDefinition operation supports updating a definition property in a hosted feature service . The result of this operation is a response indicating success or failure with error code and description .
245,979
def calc_resp ( password_hash , server_challenge ) : password_hash += b'\0' * ( 21 - len ( password_hash ) ) res = b'' dobj = des . DES ( password_hash [ 0 : 7 ] ) res = res + dobj . encrypt ( server_challenge [ 0 : 8 ] ) dobj = des . DES ( password_hash [ 7 : 14 ] ) res = res + dobj . encrypt ( server_challenge [ 0 : 8 ] ) dobj = des . DES ( password_hash [ 14 : 21 ] ) res = res + dobj . encrypt ( server_challenge [ 0 : 8 ] ) return res
calc_resp generates the LM response given a 16 - byte password hash and the challenge from the Type - 2 message .
245,980
def create_LM_hashed_password_v1 ( passwd ) : if re . match ( r'^[\w]{32}:[\w]{32}$' , passwd ) : return binascii . unhexlify ( passwd . split ( ':' ) [ 0 ] ) passwd = passwd . upper ( ) lm_pw = passwd + '\0' * ( 14 - len ( passwd ) ) lm_pw = passwd [ 0 : 14 ] magic_str = b"KGS!@#$%" res = b'' dobj = des . DES ( lm_pw [ 0 : 7 ] ) res = res + dobj . encrypt ( magic_str ) dobj = des . DES ( lm_pw [ 7 : 14 ] ) res = res + dobj . encrypt ( magic_str ) return res
create LanManager hashed password
245,981
def _readcsv ( self , path_to_csv ) : return np . genfromtxt ( path_to_csv , dtype = None , delimiter = ',' , names = True )
reads a csv column
245,982
def queryDataCollectionByName ( self , countryName ) : var = self . _dataCollectionCodes try : return [ x [ 0 ] for x in var [ var [ 'Countries' ] == countryName ] ] except : return None
returns a list of available data collections for a given country name .
245,983
def __geometryToDict ( self , geom ) : if isinstance ( geom , dict ) : return geom elif isinstance ( geom , Point ) : pt = geom . asDictionary return { "geometry" : { "x" : pt [ 'x' ] , "y" : pt [ 'y' ] } } elif isinstance ( geom , Polygon ) : poly = geom . asDictionary return { "geometry" : { "rings" : poly [ 'rings' ] , 'spatialReference' : poly [ 'spatialReference' ] } } elif isinstance ( geom , list ) : return [ self . __geometryToDict ( g ) for g in geom ]
converts a geometry object to a dictionary
245,984
def lookUpReportsByCountry ( self , countryName ) : code = self . findCountryTwoDigitCode ( countryName ) if code is None : raise Exception ( "Invalid country name." ) url = self . _base_url + self . _url_list_reports + "/%s" % code params = { "f" : "json" , } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
looks up a country by it s name Inputs countryName - name of the country to get reports list .
245,985
def createReport ( self , out_file_path , studyAreas , report = None , format = "PDF" , reportFields = None , studyAreasOptions = None , useData = None , inSR = 4326 , ) : url = self . _base_url + self . _url_create_report if isinstance ( studyAreas , list ) == False : studyAreas = [ studyAreas ] studyAreas = self . __geometryToDict ( studyAreas ) params = { "f" : "bin" , "studyAreas" : studyAreas , "inSR" : inSR , } if not report is None : params [ 'report' ] = report if format is None : format = "pdf" elif format . lower ( ) in [ 'pdf' , 'xlsx' ] : params [ 'format' ] = format . lower ( ) else : raise AttributeError ( "Invalid format value." ) if not reportFields is None : params [ 'reportFields' ] = reportFields if not studyAreasOptions is None : params [ 'studyAreasOptions' ] = studyAreasOptions if not useData is None : params [ 'useData' ] = useData result = self . _get ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , out_folder = os . path . dirname ( out_file_path ) ) return result
The GeoEnrichment Create Report method uses the concept of a study area to define the location of the point or area that you want to enrich with generated reports . This method allows you to create many types of high - quality reports for a variety of use cases describing the input area . If a point is used as a study area the service will create a 1 - mile ring buffer around the point to collect and append enrichment data . Optionally you can create a buffer ring or drive - time service area around the points to prepare PDF or Excel reports for the study areas .
245,986
def getVariables ( self , sourceCountry , optionalCountryDataset = None , searchText = None ) : r url = self . _base_url + self . _url_getVariables params = { "f" : "json" , "sourceCountry" : sourceCountry } if not searchText is None : params [ "searchText" ] = searchText if not optionalCountryDataset is None : params [ 'optionalCountryDataset' ] = optionalCountryDataset return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
r The GeoEnrichment GetVariables helper method allows you to search the data collections for variables that contain specific keywords .
245,987
def folders ( self ) : if self . _folders is None : self . __init ( ) if "/" not in self . _folders : self . _folders . append ( "/" ) return self . _folders
returns a list of all folders
245,988
def services ( self ) : self . _services = [ ] params = { "f" : "json" } json_dict = self . _get ( url = self . _currentURL , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) if "services" in json_dict . keys ( ) : for s in json_dict [ 'services' ] : uURL = self . _currentURL + "/%s.%s" % ( s [ 'serviceName' ] , s [ 'type' ] ) self . _services . append ( AGSService ( url = uURL , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) ) return self . _services
returns the services in the current folder
245,989
def createService ( self , service ) : url = self . _url + "/createService" params = { "f" : "json" } if isinstance ( service , str ) : params [ 'service' ] = service elif isinstance ( service , dict ) : params [ 'service' ] = json . dumps ( service ) return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
Creates a new GIS service in the folder . A service is created by submitting a JSON representation of the service to this operation .
245,990
def exists ( self , folderName , serviceName = None , serviceType = None ) : url = self . _url + "/exists" params = { "f" : "json" , "folderName" : folderName , "serviceName" : serviceName , "type" : serviceType } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
This operation allows you to check whether a folder or a service exists . To test if a folder exists supply only a folderName . To test if a service exists in a root folder supply both serviceName and serviceType with folderName = None . To test if a service exists in a folder supply all three parameters .
245,991
def __init ( self ) : params = { "f" : "json" } json_dict = self . _get ( url = self . _currentURL , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port ) self . _json = json . dumps ( json_dict ) self . _json_dict = json_dict attributes = [ attr for attr in dir ( self ) if not attr . startswith ( '__' ) and not attr . startswith ( '_' ) ] for k , v in json_dict . items ( ) : if k . lower ( ) == "extensions" : self . _extensions = [ ] for ext in v : self . _extensions . append ( Extension . fromJSON ( ext ) ) del ext elif k in attributes : setattr ( self , "_" + k , json_dict [ k ] ) else : print ( k , " - attribute not implemented in manageags.AGSService." ) del k del v
populates server admin information
245,992
def serviceManifest ( self , fileType = "json" ) : url = self . _url + "/iteminfo/manifest/manifest.%s" % fileType params = { } f = self . _get ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port , out_folder = tempfile . gettempdir ( ) , file_name = os . path . basename ( url ) ) if fileType == 'json' : return f if fileType == 'xml' : return ET . ElementTree ( ET . fromstring ( f ) )
The service manifest resource documents the data and other resources that define the service origins and power the service . This resource will tell you underlying databases and their location along with other supplementary files that make up the service .
245,993
def startDataStoreMachine ( self , dataStoreItemName , machineName ) : url = self . _url + "/items/enterpriseDatabases/%s/machines/%s/start" % ( dataStoreItemName , machineName ) params = { "f" : "json" } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
Starts the database instance running on the Data Store machine .
245,994
def unregisterDataItem ( self , path ) : url = self . _url + "/unregisterItem" params = { "f" : "json" , "itempath" : path , "force" : "true" } return self . _post ( url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
Unregisters a data item that has been previously registered with the server s data store .
245,995
def validateDataStore ( self , dataStoreName , machineName ) : url = self . _url + "/items/enterpriseDatabases/%s/machines/%s/validate" % ( dataStoreName , machineName ) params = { "f" : "json" } return self . _post ( url = url , param_dict = params , securityHandler = self . _securityHandler , proxy_url = self . _proxy_url , proxy_port = self . _proxy_port )
Checks the status of ArcGIS Data Store and provides a health check response .
245,996
def layers ( self ) : if self . _layers is None : self . __init ( ) lyrs = [ ] for lyr in self . _layers : lyr [ 'object' ] = GlobeServiceLayer ( url = self . _url + "/%s" % lyr [ 'id' ] , securityHandler = self . _securityHandler , proxy_port = self . _proxy_port , proxy_url = self . _proxy_url ) lyrs . append ( lyr ) return lyrs
gets the globe service layers
245,997
def loadFeatures ( self , path_to_fc ) : from . . common . spatial import featureclass_to_json v = json . loads ( featureclass_to_json ( path_to_fc ) ) self . value = v
loads a feature class features to the object
245,998
def fromFeatureClass ( fc , paramName ) : from . . common . spatial import featureclass_to_json val = json . loads ( featureclass_to_json ( fc ) ) v = GPFeatureRecordSetLayer ( ) v . value = val v . paramName = paramName return v
returns a GPFeatureRecordSetLayer object from a feature class
245,999
def asDictionary ( self ) : template = { "type" : "simple" , "symbol" : self . _symbol . asDictionary , "label" : self . _label , "description" : self . _description , "rotationType" : self . _rotationType , "rotationExpression" : self . _rotationExpression } return template
provides a dictionary representation of the object