Two men have avoided jail - one 'by a knifes edge' - after police caught them in a property being used to sell crack cocaine and heroin.