Raspberry Pi automatic Initialization Script

Source: Internet
Author: User

#! /Bin/ENV Python
#-*-Coding: UTF-8 -*-
# Revision:
# Date: 2012-12-10
# Author: simonzhang
# Email: simon-zzm@163.com
# Web: www.simonzhang.net
#-------------------------------
Import OS
Import time
 
Def systemupdate (): # system upgrade
Try:
OS. System ('sudo apt-get-y Update ')
_ Get = 'OK'
Except t:
_ Get = 'error'
Return _ Get
 
Def timing (): # School hour
Try:
OS. System ('sudo CP/usr/share/zoneinfo/Asia/Shanghai/etc/localtime ')
OS. System ('sudo apt-Get install-y ntpdate ')
OS. System ('sudo/usr/sbin/ntpdate stdtime.gov.hk ')
_ Get = 'OK'
Except t:
_ Get = 'error'
Return _ Get
 
 
Def vncserver (): # Remote Desktop
Try:
OS. System ('sudo apt-Get install-y tightvncserver ')
_ Get = 'OK'
Except t:
_ Get = 'error'
Return _ Get
 
 
Def developtool (): # Development Tool
Try:
OS. System ('sudo apt-Get install-y GCC make ')
_ Get = 'OK'
Except t:
_ Get = 'error'
Return _ Get
 
Def systemtools (): # Common System Tools
Try:
OS. System ('sudo apt-Get install-y bison gawk Vim chkconfig ')
_ Get = 'OK'
Except t:
_ Get = 'error'
Return _ Get
 
 
Def pythontools (): # Python management tool
Try:
OS. System ('wget-Q http://peak.telecommunity.com/dist/ez_setup.py ')
OS. System ('sudo Python ez_setup.py ')
OS. System ('sudo easy_install pygame ')
_ Get = 'OK'
Except t:
_ Get = 'error'
Return _ Get
 

Def pythonimage (): # Python Image Processing
Try:
OS. System ('sudo apt-Get install-y libjpeg *-dev ')
OS. System ('sudo apt-Get install-y Python-imaging ')
OS. System ('sudo apt-Get install-y Python-dev ')
OS. System ('sudo easy_install tornado Pil ')
_ Get = 'OK'
Except t:
_ Get = 'error'
Return _ Get
 
 
Def pythonframe (): # Python framework
Try:
OS. System ('sudo easy_install tornado Django ')
_ Get = 'OK'
Except t:
_ Get = 'error'
Return _ Get
 
Def opencv (): # camera
Try:
OS. System ('sudo apt-Get install-y Python-opencv ')
_ Get = 'OK'
Except t:
_ Get = 'error'
Return _ Get
 
 
Def installmysql (): # Database, password: pi
Try:
OS. System ('sudo debconf-set-selections <\ 'mysql-server-5.5 mysql-server/root_password password pi \'')
OS. System ('sudo debconf-set-selections <\ 'mysql-server-5.5 mysql-server/root_password_again password pi \'')
OS. System ('sudo apt-get-y install mysql-Server ')
_ Get = 'OK'
Except t:
_ Get = 'error'
Return _ Get
 
 
Def installjava (): # Java environment
Try:
OS. System ('sudo apt-Get install-y openjdk-7-jdk ')
_ Get = 'OK'
Except t:
_ Get = 'error'
Return _ Get
 
Def chinesefont (): # Chinese font
Try:
OS. System ('sudo apt-Get install-y TTF-wqy-microhei ')
_ Get = 'OK'
Except t:
_ Get = 'error'
Return _ Get

Def inputmethod (): # Input Method
Try:
OS. System ('sudo apt-Get install-y scim-pinyin ')
_ Get = 'OK'
Except t:
_ Get = 'error'
Return _ Get
 

Def audiodriver (): # audio
Try:
OS. System ('sudo apt-Get install-y ALSA-utils ')
OS. System ('sudo modprobe snd_bcm2835 ')
_ Get = 'OK'
Except t:
_ Get = 'error'
Return _ Get
 

Def main ():
Install_list = [systemupdate ,\
Timing ,\
Vncserver ,\
Developtool ,\
Systemtools ,\
Pythontools ,\
Pythonimage ,\
Pythonframe ,\
Opencv ,\
Installmysql ,\
Installjava ,\
Chinesefont ,\
Inputmethod ,\
Audiodriver ,\
Systemupdate,
]
For il in install_list:
Print '* 50
Print ': % s start' % Il
Print '* 50
Install_status = il ()
Nt = time. localtime ()
Log_time = "% s-% S % s: % s" % (NT [2], NT [2], NT [3], NT [4], NT [5], NT [6])
LOG_FILE = open ("pi_install.log", "AB ")
Log_file.write ("% S % s install % s \ n" % (log_time, Il, install_status ))
Log_file.close ()
OS. System ('sudo apt-Get upgrade-y ')
Print "Install all end ."
 
 
If _ name _ = '_ main __':
Main ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.