A drink-driver was so inebriated he tried to open the front door of his house using a phone charger.
Imran Safi was visited by police officers, who had found his Vauxhall Astra abandoned in Dunfermline.
Before ditching his car, Safi had been seen careering into a set of traffic lights, knocking them down completely.
When tested at the police station more than two hours after the crash the 31-year-old was found to be six times the legal limit.
At Dunfermline Sheriff Court, a sheriff warned him he had narrowly escaped a prison sentence.
Smashed into traffic lights
Fiscal depute Mat Piskorz told the court the incident had happened in the early evening.
He said: “At 7.55pm witnesses saw the accused’s vehicle drive on Aberdour Road and drive over a pedestrian island and a ‘keep left’ sign, causing damage to both.
“It then turned left onto Queensferry Road, where it came to a stop.
“The witness contacted police to make them aware of the damage.
“Simultaneously the police received a call from a member of the public reporting the accused’s vehicle crashing into his fence and causing damage to a set of traffic lights.
“Police arrived at Aberdour Road and observed that the traffic lights had been completely knocked down and there was debris over the road causing an obstruction to other road users.
“The accused’s vehicle was observed crashed at Pitbauchlie Bank and there was no one inside.”
Phone charger
He said officers traced Safi at his home.
“He appeared heavily intoxicated and was struggling to unlock his front door using a phone charger.
“He was in possession of car keys from the offending vehicle.”
Safi admitted he had been the driver and was taken to Kirkcaldy’s Victoria Hospital, where he began abusing police officers, who had to call in reinforcements.
He was later taken to the police station and failed a breath test at around 10.30pm.
Narrowly escaped prison term
Safi, of Ferry Road, Edinburgh, admitted driving dangerously on May 3.
He further admitted driving with 132 mics of alcohol on his breath, against the legal limit of 22 and acting in a threatening and abusive manner at Kirkcaldy’s Victoria Hospital.
Solicitor Elaine Buist said Safi is the manager with a security firm and has moved to Edinburgh as there are better public transport links to get to work.
She said Safi’s recollection of events is “hazy”.
Sentencing him, Sheriff Charles Macnair said: “It’s only by the greatest good fortune you did not cause physical harm to anyone.
“The only thing that’s keeping you out of prison is your lack of long record.”
He ordered Safi to carry out 300 hours of unpaid work.
He also disqualified him from driving for 27 months and ordered him to sit the extended test before he gets back behind the wheel.