blank_program's Profile User Rating: -----

Reputation: 11 Tradesman
Active Posts:
290 (0.12 per day)
22-July 09
Profile Views:
Last Active:
User is offline Private

Previous Fields

OS Preference:
Favorite Browser:
Favorite Processor:
Favorite Gaming Platform:
Your Car:
Dream Kudos:

Latest Visitors

Icon   blank_program has not set their status

Posts I've Made

  1. In Topic: Python 3 MySQL module preference?

    Posted 21 Apr 2015

    The server I will be using is running MariaDB 10 which is a fork of MySQL but drop in replacement. So it does help but is one that I was looking at.
  2. In Topic: Reuse line for input()

    Posted 7 Jan 2015

        while os.path.isdir(dir) and string not in dir:
            dir = os.path.abspath(input('Invalid directory, please re-enter the directory: '))

    I would like to clean and reuse the same line for all input lines.
  3. In Topic: Download images and keep structure

    Posted 31 Oct 2014

    There is a link to photos on the home page and a drop down to only display those from a certain month and year. I feel like it would be easiest for automation to just replicate the structure so I don't end up with a folder full of images. Which I guess I could do a shell script or another Python one to sort out after but that will be cumbersome.

    Since some images from the site may be NSFW without sanitizing the current code I do not think it would be allowed to post the exact links.
  4. In Topic: Code check/help

    Posted 2 Jun 2014

    Does this look any better? Email functionality based on Python documentation added but not tested. commented out for testing. Tested on Debian and seems to work, except email code I did not add, but I know I need error handling.
    from email.mime.text import MIMEText
    import pwd
    import random
    import smtplib
    import string
    import subprocess as sp
    class User:
    	def __init__(self, name):
    		self.fullname = name
    		self.username = ''
    		self.password = ''
    		self.email_addr = ''
    	def chuserid(self):
    		#attempt to check if user name already exists by checking /etc/passwd for username
    		#just continue if user does not exist as this is non-fatal
    		userchk = ''
    			userchk = pwd.getpwnam(self.username).pw_name
    		#if user exists then simply reset the password for the specified user
    		#create user if they do not exist
    		if userchk == self.username:
    			print("User found. Setting new password.")
    			print("User not found. Creating account.")
    	def createuser(self):
    		#create user and set comment field to full name for documentation purposes
    		sp.check_call(["/usr/sbin/useradd", "-c" + self.fullname, "-m", self.username.lower()])
    		print(self.username.lower() + " added successfully")
    	#function that accepts a users full name and builds a username and email address
    	def geninfo(self):
    		#split full name to form email address and username
    		#user name should be first initial then full last name
    		splname = self.fullname.split(' ')
    		#input should be at least first and last name but may include middle initial to prevent duplication
    		if len(splname) == 2:
    			#email address is [email protected]
    			self.email_addr = splname[0] + "." + splname[1] + ""
    			self.email_addr = self.email_addr.lower()
    			#username is first initial followed by last name
    			self.username = splname[0][0] + splname[1]
    		elif len(splname) == 3:
    			#placeholder address until standard address format is set for name collisions
    			self.email_addr = ""
    			#DO NOT USE - disabled until standard is set, left in as template for future use
    			#append middle initial to end of first name of format [email protected]
    			#self.email_addr = splname[0] + "." + splname[1][0] + "." + splname[2] + ""
    			self.email_addr = self.email_addr.lower()
    			#username is first initial followed by last name
    			self.username = splname[0][0] + splname[1][0] + splname[2]
    		#if name is not first and last or first middle last then prompt again
    		#force userid to lowercase due to case sensitivity
    		self.username = self.username.lower()
    		#check if userid currently exists
    	#set password for specified user account using psuedo-random number appended to userid
    	#NOT SECURE but password set for ease of use by end user
    	def setpassword(self):	
    		#generate random password for user based on userid and random set of digits
    		#NOT SECURE but designed for ease of use by end user
    		self.password = self.username + '.' + ''.join(random.choice(string.digits) for _ in range(5))
    		#temporarily print password for testing purposes
    		#hash password and assign it to new user account using built in functions
    		passin = sp.Popen(("mkpasswd", "-m", "sha-512", self.password), stdout=sp.PIPE)
    		hpass = passin.communicate(self.password.encode())[0].strip()
    		hpass = hpass.decode()
    		sp.check_call(["usermod", "-p", str(hpass), self.username])
    	#email user from template notifying them of the set login credentials
    	def emailnotice(self):
    			notice_template = "/root/notice.txt"
    			addr_from = ''
    			addr_to	= self.email_addr
    			msg_body = ''
    			msg_subject = ''
    			smtp_user = "[email protected]"
    			smtp_password = ''
    			smtp_server = ''
    			#read SMTP password from file with restricted access
    			with open("/root/secret.txt", 'r') as sf:
    				smtp_password =
    			#read notice message from file with restricted access
    			with open(notice_template, 'r') as nf:
    				msg_body =
    			#replace template variable text with information specific to user
    			msg_body = msg_body.replace('ppppp', self.password)
    			msg_body = msg_body.replace('uuuuu', self.username)
    			#build email message
    			notice = MIMEText(msg_body)
    			notice['From'] = addr_from
    			notice['Subject'] = msg_subject
    			notice['To'] = addr_to
    			#s = smtplib.SMTP(smtp_server)
    			#s.login(smtp_user, smtp_pass)
    def main():
    	inname = input("Enter user's fullname: ")
    	user = User(inname)
    if __name__ == "__main__":

My Information

Member Title:
D.I.C Regular
Age Unknown
Birthday Unknown

Contact Information

Website URL:
Website URL  http://