[GIS] How to check out arcgis 10.2 desktop license using arcpy

arcgis-10.2arcgis-desktoparcgis-license-managerarcpy

Referring to ArcGIS help it seems possible to check out advanced desktop license. But typing
arcpy.CheckOutExtension('ArcInfo')

gives

Unrecognized extension code ArcInfo

Best Answer

As the documentation states:

"SetProduct is a legacy; importing modules needs to be done before importing arcpy".

http://resources.arcgis.com/en/help/main/10.2/index.html#/SetProduct/03q30000000v000000/

The script might go something like this:

import arcinfo  
import arcpy

if arcpy.CheckProduct("ArcInfo") == "Available":  
    execute code  
else:  
    print "Error message"