- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
The problem in modern dev isn't that we have so many typewriters. It's that we have so many monkeys.
I scarcely know where to begin on this ... atrocity.
Admin
I hope the environment is strictly controlled, because the first loop fails miserably if someone manages to create a file in the otherwise empty directory while nothing is mounted there, seeing as how the automatic mount will calmly hide those files when the drive is actually inserted, but the file will be detected and the loop will end as if there is an actual USB key mounted...
Admin
Detecting a new USB drive isn't all that easy, so doing the directory listing isn't a completely insane way to do it.
The other minor WTF that isn't mentioned is that "usb drv not detected" gets sent even when the drive is detected.
Admin
I've always preferred
ture
tofasle
.Admin
Well, actually the patch check is sane. In modern Linuxen the removable media mount path is like that:
/media/LOGIN/MEDIA_LABEL/media_contents
(sometimes/run/media/...
).So the assumption is that user running script has its login named exactly
update
. Thenos.listdir('/media/update')
lists all mounted pendrives by their labels.All the other logic is botched, but this one part is OK.
Admin
Hammer, meet nail. Nail, meet hammer.
Admin
"Abandon all hope, ye who enters here".
I mean, seriously, you should stop using the phrase "environment is controlled" - if they have such a standard for their code, they wouldn't even understand the meaning of the phrase, even if you handed them the dictionary.
Yes, speaking from experience.
Admin
Borrow some real-world pythons from some snake geek.
Let them loose in the office.
Admin
As regular TDWTF readers should know,
path.exists
will return the boolean valueFileNotFound
... probably.Admin
These aren't even nails. They're rocks pounded in with bigger rocks.
Admin
HAHAHAHA I recently worked on something very similar and was afraid for a second this was about my code, but then I read to "Python" and breathed a sigh of relief (my stuff is in C#).
Having read the full article, it's needless to say that I would never write something as bad as this - but the first few words of the first paragraph did get me. :)
Admin
Not only do they need the logged-in user to be named 'update', they also need that user logged in to some sort of session which auto-mounts USB devices. Typically, even standard desktop environments just notice and allow the user to mount it manually.
It's possible to have a USB device auto-mount, under specific circumstances, and do something afterwards, but this method is not it.
Admin
twitches at yet another idiot treating a simple value as a string
C'mon. It's a boolean. There's no need to stringify a boolean. It's an ON/OFF state, the very building blocks of computers. If you haven't been taught this much on day one of your training (which was probably an online "learn to be a h4x0r in 20 minutes!!1!" course), then it was a waste.
I think I have found the button that turns me into interesting shades of crimson.
Admin
How can I get a contract to be a freelancer that gets to write this code? Did this take him(her) a long time? Was this the whole contract? Can I get paid the same way?
Admin
How can I get a contract to be a freelancer that gets to write this code? Did this take him(her) a long time? Was this the whole contract? Can I get paid the same way?
Admin
There's no event from the OS whether a new drive has been mounted/unmounted, that you could subscribe to?
Admin
I really love the inconsistency in the Python string syntax. Oh come on, we can debate all day on the merits of double quotes over single quotes, but is it so hard to choose one and just stick to it?
That's one of the red flags that makes me want to throw that piece of garbage in /dev/null.
Admin
There's likely multiple better ways to do this, but that might imply reading some documentation when it's so much easier to reinvent (poorly) the wheel.
Admin
Ref You Name's very sensible point ...
A legit problem with so much code being written in various scripting languages is that a) there often really are OS events published by an OS API that user code written in real full-featured languages can subscribe too. But b) that API is not surfaced in the training wheel / OS-agnostic world of python, javascript, etc.
A secondary problem is one of training. Script jockeys are generally going to struggle with the arcana of interfacing to Windows or iOS or Linux's APIs. Many of which were designed in an era of assembler as the primary user-mode code language. Not so hard to interface with using C or equivelent. Much more challenging for newer / higher langs.
A script language with fully debugged reliable OS abstraction layers available as built-in libraries would bridge a lot of this gap. Would.
Admin
Possibly buf10 is simply preceded by buf1, and followed by buf11, buf100, buf101 …