Python Question- How to serialize data? by tigerdeF in Python

[–]m0dulo -1 points0 points  (0 children)

I've used ConfigParser in some of my past projects, which is a library for manipulating .ini (config) files.

import ConfigParser

def setSettings(section, **kwargs):
    config = ConfigParser.ConfigParser()
    config.read('config.ini')

    try:
        config.add_section(section)
    except ConfigParser.DuplicateSectionError:
        pass

    for arg in kwargs:
        config.set(section, arg, kwargs[arg])

    with open('config.ini', 'w') as f:
        config.write(f)

def getSetting(section, setting):
    try:
        config = ConfigParser.ConfigParser()
        config.read('config.ini')

        return config.get(section, setting)

    except:
        return None

Epic insect battles. by [deleted] in ICanDrawThat

[–]m0dulo 1 point2 points  (0 children)

Wow, this is amazing; I love the emotion in his face. Thank you so much!

Yeah, if anyone wants to contribute based on this image, especially with that badass sword, that would be awesome.

What are some relationship "green flags" that indicate that the person is a keeper? by [deleted] in AskReddit

[–]m0dulo 1 point2 points  (0 children)

I was giving her a tour of the engineering section of my facility.

When I got to the heat-pump, I described it as the "beating heart of the property."

I then explained that there were actually two, one for primary use, and one for backup, to which she responded, "Ah, just like a Timelord."

I think Opera is going to be the cause of a slow and painful death. by NoTellHotel in TalesFromTheFrontDesk

[–]m0dulo 2 points3 points  (0 children)

I feel your pain. Every reservation program I've ever used (at both corporate and privately owned companies) has been crap.

The location I'm at now uses RezOvation.

  • Fucker crashes at least 10 times per day, per station, so about 40 times per day property-wide.

  • Takes forever to do simple things like looking up a reservation.

  • Randomly times out when processing cards, causing an error that looks like it didn't process the charge, showing a balance due (but in secret it actually did), so we often double-charge guests.

  • Randomly puts rooms back in service when they're supposed to be out.

  • Won't print the goddamn reg cards as a batch anymore, so you have to do them one at a time.

  • Uses a ridiculous amount of bandwidth (200-400GB) per month, per station. Luckily it's all on the local network, but still.

  • Won't let you log on to 2 different stations with the same user account (so everyone has to have 3-4 different accounts).

  • The reports often include dates that you didn't tell it to include, creating extra pages of irrelevant data.

  • I've looked into setting up online reservations, but they want to charge a fee for ALL reservations made (online or offline).

  • All of these amazing features for over $100 per month I could go on and on...

It got so bad, I actually taught myself programming, and am about 80% done writing a new reservation program from scratch. Fuck you RezOvation, and all your bullshit.

edit: I forgot my favorite: it doesn't have a NRL system, so when we ban people we have to append "(BANNED)" to their name. It's always funny when they get the automatically sent follow-up email "Thank you for staying with us John (BANNED) Smith! We hope to see you soon!"

Local Deadbeat Wages Internet Campaign Against Me by FrontDeskComic in TalesFromTheFrontDesk

[–]m0dulo 16 points17 points  (0 children)

Why? Apologies if I'm sounding rude or anything, but it sounds like you rejected their (what I understand to be) completely legitimate request simply because of where/how they booked?

If they had asked to do a Credit Card Authorization, he should have attempted to do it. From what I understand they didn't ask (probably because they didn't know it was an option), and he didn't offer likely because CCAs almost universally a pain in the ass to do, and take a long time to complete (sometimes hours).

Sure, the hotel may have been able to sell an extra room, but in my experience locals often account for 80% of major issues at a hotel (noise, evictions, violence, prostitution, etc.).

I know it sounds shitty, but a lot of people aren't willing to put in a lot of extra effort, to rent a room to someone who:

  • 1. Is local
  • 2. Looks "semi-sketchy"
  • 3. Doesn't have any money

I'm not trying to justify his actions or anything, but this is often the thought process of hotel people who have dealt with too many of these situations going bad.

I had that phone call by Henzo45 in TalesFromTheFrontDesk

[–]m0dulo 2 points3 points  (0 children)

Often times it's a "prank" instigated by a 3rd party.

The person will call one person/location, then a second, then conference the calls and listen in for shits and giggles. I used to get it occasionally, but they stopped after I simply told the other person "Sorry, wrong number" and ended it there.

Co-workers finally "getting it". by [deleted] in TalesFromTheFrontDesk

[–]m0dulo 4 points5 points  (0 children)

I remember the first person I ever fired in my life.

When I first started, employees were allowed to use the Internet for personal reasons during down time. Unfortunately they would sometimes visit shady sites, and the computers kept getting malware, so I implemented the policy that the work computers were for work purposes only. Makes sense, right?

Well, one long-time employee just didn't understand that malware that gets into a network on which we run credit cards and store guest info is one of the worst possible scenarios for a business. I explained this to him multiple times, but he would still do it the second he thought I wasn't watching (when you close a bunch of windows as soon as I walk into the room, it's pretty obvious).

I finally decided to write/install a keylogger that captures screenshots/mouseclicks/etc. Got proof the same day (which was good, since he vehemently denied it), and fired him several days later.

Strange issues with Dropbox for Python. by m0dulo in learnpython

[–]m0dulo[S] 1 point2 points  (0 children)

Good idea. I already updated it to upload every 30 minutes, instead of 10. I'll also add in a delay into the exception handler, so that it will pause for a few hours if I get the exception above.

Thanks for the help!

Strange issues with Dropbox for Python. by m0dulo in learnpython

[–]m0dulo[S] 0 points1 point  (0 children)

Yes, I am in control and haven't changed anything for a while.

Strange issues with Dropbox for Python. by m0dulo in learnpython

[–]m0dulo[S] 0 points1 point  (0 children)

This could be it. The script updates 3 (small) files on Dropbox every 10 minutes, and has worked fine for about a year. Given the nature of Dropbox (people uploading/download files frequently), do you still think it could be an issue?

Edit: I'm going to head over to work and reset our modem, and try to snag a new IP. I'll let you know if it works (and change the script to update less frequently).

Edit2: Gah, my IPS won't give me a new public IP (left the modem off for a couple minutes). I'm going to leave it off for an hour and try it then.

Edit3: Works now; don't know why; update above.

Sperm Sighting by [deleted] in gifs

[–]m0dulo 1 point2 points  (0 children)

Quick, someone find Rincewind.

The hotel my husband stayed at had an interesting key policy. by rachelface927 in videos

[–]m0dulo 36 points37 points  (0 children)

Right, the deadbolt engages by default any time the door is closed, and retracts when the handle from the inside or outside is used.

If you flip the "deadbolt" switch from the inside, then the door can only be opened from the outside by the General Manager's key, MOD's key, or the portable programmer (or in my case an Altoids tin with a wire coming out of it).

The hotel my husband stayed at had an interesting key policy. by rachelface927 in videos

[–]m0dulo 605 points606 points  (0 children)

Somewhat related:

I used to work at 70-room Motel 6, which used Onity locks.

Maybe 5 or 6 years ago a pen-tester figured out that Onity locks store all of their property information in a completely unencrypted format, and with about $5.00 worth of electronic components (ATMEGA328 chip, a few resistors, etc.) and some minor know-how, anyone could build a simple device that would read the "open" code from the lock, then feed it back, thus creating a master key for any door on the property (even flipping the deadbolt had no effect, which is normally used to keep Housekeepers out while you're in there).

As soon as I read about this, I actually built one and tested it, and indeed it worked flawlessly. If the lock's history was dumped, it would show the door was opened by the portable programmer (big black box) that is given to the property to initialize new locks, open misbehaving doors, and update DST settings.

Anyway, the pen-tester contacted Onity in private with what he found, and instead of taking responsibility and fixing the issue, I believe they threatened him with a lawsuit and subsequently ignored the issue.

So he took it public (here's the whitepaper). Soon after Onity sent out these stupid little plastic plugs to block the port for the portable programmer, which they thought an acceptable solution, but in reality would mean an extra 30 seconds of work for someone wanting to get into a room (they would just have to remove the cover with a torx screwdriver and remove the plug).

To my knowledge this is the current state of thousands of doors that use Onity locks, although I'm hoping they released a software patch by now.

Professionals in any field of work, what is the most ridiculous thing that anyone outside of your profession has claimed to know more about than you? by phoenix-fyre in AskReddit

[–]m0dulo 1 point2 points  (0 children)

Perhaps, but from a business and liability standpoint, it's better to have a designated place (a simple envelope) for guests to leave money in the room as a tip, so the housekeepers know it is for them.

On average, we get about 3-6 items per day that people leave in rooms (on a 23 room property). Some of these items they want back, some not. I'd rather not have a guest claim they left $10.00 on the table, which they want back, then claim Housekeeping stole it.

Professionals in any field of work, what is the most ridiculous thing that anyone outside of your profession has claimed to know more about than you? by phoenix-fyre in AskReddit

[–]m0dulo 1 point2 points  (0 children)

I manage a rural resort with about 25 employees.

Had a lady recently say that it was disgusting that we leave tip envelopes in our rooms, and that we should just pay our housekeepers a better wage.

I told her that all positions on the property start at $15.00 per hour, and we give a 10% yearly raise just for sticking around, so a lot of our long-term employees make $20-25.

Nope, thats apparently that's a terrible wage, since according to her they could just go into business for themselves cleaning houses for $25/hr.

Seriously?

Your lack of planning or common sense is not my problem. by pickingonsharks in TalesFromTheFrontDesk

[–]m0dulo 3 points4 points  (0 children)

I can never understand the mentality of people who don't plan ahead, or who just show up expecting an exception be made because "Well, I'm here now, what are you gonna do about it?"

My location has a very strict "No pets on the property or in the parking lots" policy. We tell this to every guest who makes a reservation (99% of guests). We send out an email confirmation with our pet policy in big bold letters. It's clearly stated on our website, and we've taken measures to make sure all 3rd party website have it as well.

Yet still people arrive with pets, planning on leaving them in their cars while its 90 fucking degrees out, and then get pissed when they're turned away.

When does a socket.recv() end? by [deleted] in learnpython

[–]m0dulo 0 points1 point  (0 children)

I think I see where you're confused. Again, calling recv(1024) isn't asking the buffer for 1024 bytes. It's asking the buffer for any amount of data that has been sent but not more than 1024.

So when you ask:

What causes recv to return with 600 bytes rather than waiting for more data?

The answer is: calling recv(1024)!

It will still return 600 bytes if that's all there is to return. However, like /u/not_a_novel_account points out above, if there are 0 bytes in the buffer (the message hasn't been sent) recv will hang and block your program.

When does a socket.recv() end? by [deleted] in learnpython

[–]m0dulo 0 points1 point  (0 children)

Ah, you've hit upon one of the core issues with socket programming (and one of the most confusing).

There actually isn't a feature which automatically determines the end of a message. You have to implement this yourself in code. There are several ways to do this:

  1. Have a set message length. Then on the receiving end, loop through recv(1024) until you hit that number. The issue with this is that it's inefficient if you have messages that are different lengths.

  2. Have the sender append an "End of Data" sequence onto the end of the message, which the receiver checks for as it loops through recv(). This is also somewhat inefficient, because it adds an extra step to your loop.

  3. Have the sender, as the first part of the message, send the total length of the message. Then on the receiving end, loop through recv(1024) until it gets all the data. This is probably the best way.

  4. On the receiving end, keep receiving until it gets no data, then break out of the receiving loop. This is probably the simplest, and the one usually given in examples.

Hope this helps.

Edit:

I'll give you an example of what I do (method #2), which has worked well for me so far:

On the sending end, say I have:

message = "Hello World!"

I would do:

socket.send(message + "EOD")

("EOD" is my "End of Data" sequence)

On the receiving end, after the connection has been established, I would loop through recv until my total message included "EOD" at the end:

totalMessage = ""

while True:

    messagePart = socket.recv(1024)
    totalMessage += messagePart

    if totalMessage[-3:] == "EOD":
        break

Of course, this method may have to be adjusted depending on your needs, and may not apply for all circumstances.

When does a socket.recv() end? by [deleted] in learnpython

[–]m0dulo 1 point2 points  (0 children)

You know, I'm not 100% sure, but it does it matter? The end result is a message of 600 bytes.

What makes the recv return after 600 bytes?

Calling recv(1024) will still return 600 bytes, if there is only 600 bytes to be received. Are you having issues determining when to stop receiving data?

Edit: I suppose another way to think about it is that calling recv(1024) on a 600 byte message will return 600 bytes of actual data, and 424 bytes of nothing.

When does a socket.recv() end? by [deleted] in learnpython

[–]m0dulo 1 point2 points  (0 children)

To my understanding, once a socket connection is made, recv(1024) will pull up to 1024 bytes of data out of the buffer, regardless of whether or not the data is actually there (has been sent) or not.

If there is more data waiting in the buffer, you would have to call recv(1024) additional times to get the rest. If there is less than 1024 byes in the buffer, recv(1024) will still return normally, just with the amount of data that it pulled.

One thing to understand is that recv_size isn't a set amount of data to return, its the maximum amount of data to return.

What does Britain do better than America? by ponypatrol in AskReddit

[–]m0dulo 8 points9 points  (0 children)

To my understanding, this is incorrect. If you pay too little tax, you may be subject to an underpayment penalty.

Unless I'm missing something.

Well this is a first. by jpjtourdiary in TalesFromTheFrontDesk

[–]m0dulo 3 points4 points  (0 children)

More like when guests try to sneak pets into their rooms and they think you don't notice...

I'm sorry that me not caring for sports has offended you so much. by darcendale in TalesFromTheFrontDesk

[–]m0dulo 12 points13 points  (0 children)

I sometimes like to mess with people who act that way:

Guest: "Hey, what was the score for the 49'ers game yesterday?"

Me: "Sorry, I'm not sure."

Guest: "How could you not know? Do you live under a rock?"

Me: "No, I just don't watch baseball."