AnsweredAssumed Answered

arcpy.listusers(workspace) not giving consistent results

Question asked by ben_vk on Apr 26, 2015
Latest reply on Apr 30, 2015 by ben_vk

Hi All,


I have been running the below line in python, trying to build a list of PC numbers that I can use elsewhere in my script. As PC numbers/names can vary in length I have to modify the output of arcpy.listUsers() to clip the version name which is appended to the ClientName part of the output.


So to clarify what I am doing:

import arcpy
current_users = arcpy.ListUsers(r'Database Connections\GISADMIN@SDE_Spatial@Smithy.sde')

for user in current_users:
     print user


this outputs my users currently connected to the DB, this is an example output:

user(ClientName=u'ACC5283-12:', ConnectionTime=datetime.datetime(2015, 4, 27, 12, 21, 48, 1), ID=66566, IsDirectConnection=True, Name=u'GISADMIN')

user(ClientName=u'ACC5285-12:', ConnectionTime=datetime.datetime(2015, 4, 27, 13, 13, 17), ID=66589, IsDirectConnection=True, Name=u'"ALBURY\\KERRIERO"')

user(ClientName=u'ACC5623-12:', ConnectionTime=datetime.datetime(2015, 4, 27, 13, 36, 35), ID=66594, IsDirectConnection=True, Name=u'"ALBURY\\KADENBR"')

user(ClientName=u'ACC5279-12', ConnectionTime=datetime.datetime(2015, 4, 27, 14, 16, 21), ID=66599, IsDirectConnection=True, Name=u'"ALBURY\\PATREAON"')


Now in order for my script to work I have to make all the ClientNames similar, so what I need is basically 'ACCXXXX-12', and cut off the rest of the clientName which I believe is the version the user is running. Normally I would simply do

     print user.ClientName[:-12]

and this would be fine, but as the ClientName is not consistent it is breaking my code.


See in my output, the user PatreaON (PC name is ACC5279-12), it for some unknown reason does not include the version number.


And that is my problem, is anyone able to tell me why this users output is different to everybody elses?


P.S unfortunately I cannot simply use user.ClientName[0:10] as the pc numbers range from 0-6000, meaning varying length, and ACC is for my current site, this also varies.


Any ideas as to why this user is different?