/Pythonxiaojiaoben

My Python Examples

Primary LanguagePythonMIT LicenseMIT

My Python Examples

I do not consider myself a programmer. I create these little programs as experiments to play with the language, or to solve problems for myself. I would gladly accept pointers from others to improve, simplify, or make the code more efficient. If you would like to make any comments then please feel free to email me at craig@geekcomputers.co.uk.

These scripts contain important functions which help reduce human workload. Code documentation is aligned correctly when the files are viewed in Notepad++.

  • batch_file_rename.py - This batch renames a group of files in a given directory, once you pass the current and the new extensions.

  • create_dir_if_not_there.py - Checks to see if a directory exists in the users home directory, if not then create it.

  • Fast Youtube Downloader - Downloads YouTube videos quickly with parallel threads using aria2c

  • Google Image Downloader - Query a given term and retrieve images from the Google Image database.

  • dir_test.py - Tests to see if the directory testdir exists, if not it will create the directory for you.

  • env_check.py - This script will check to see if all of the environment variables required are set.

  • fileinfo.py - Shows file information for a given file.

  • folder_size.py - Scans the current directory and all subdirectories and displays the size.

  • logs.py - This script will search for all *.log files in the given directory, zip them using the program you specify, and then date stamp them.

  • move_files_over_x_days.py - Moves all files over a specified age (in days) from the source directory to the destination directory.

  • nslookup_check.py - This simple script opens the file server_list.txt and then does an nslookup for each one to check the DNS entry.

  • osinfo.py - Displays some information about the OS on which you are running this script.

  • ping_servers.py - This script, depending on the arguments supplied, will ping the servers associated with that application group.

  • ping_subnet.py - After supplying the first 3 octets this file scans the final range for available addresses.

  • powerdown_startup.py - This file goes through the server list and pings the machine, if it is up it will load the putty session, if it is not it will notify you.

  • puttylogs.py - This file zips up all the logs in the given directory.

  • script_count.py - This file scans the scripts directory and gives a count of the different types of scripts.

  • [get_youtube_view.py] - This is very simple python script to get more views for your youtube videos.Some times I use for repeating my favorite songs by this scripts.

  • script_listing.py - This file will list all the files in the given directory, and go through all the subdirectories as well.

  • testlines.py - This simple script opens a file and prints out 100 lines of whatever is the set for the line variable.

  • tweeter.py - Allows you to tweet text or a picture from the terminal.

  • serial_scanner.py contains a method called ListAvailablePorts which returns a list with the names of the serial ports that are in use in the computer. This method works only on Linux and Windows (can be extended for mac osx). If no port is found, an empty list is returned.

  • get_youtube_view.py - A simple python script to get more views for your YouTube videos. Useful for repeating songs on YouTube.

  • CountMillionCharacter.py And CountMillionCharacter2.0.py - Gets character count of a text file.

  • xkcd_downloader.py - Downloads the latest XKCD comic and places them in a new folder called "comics".

  • timymodule.py - A great alternative to Pythons 'timeit' module and easier to use.

  • calculator.py - Uses Python's eval() function to implement a calculator.

  • Google_News.py - Uses BeautifulSoup to provide Latest news headline along with news link.

  • cricket_live_score - Uses BeautifulSoup to provide live cricket score.

  • youtube.py - Takes a song name as input and fetches the YouTube URL of the best matching song and plays it.

  • site_health.py - Checks the health of a remote server

  • SimpleStopWatch.py - Simple Stop Watch implementation using Python's time module.

1、batch_file_rename.py 批量重命名指定目录下面所有文件的后缀名。

2、create_dir_if_not_there.py 如果不存在的目录。

3、Fast Youtube Downloader 多线程高速下载Youtube视频。

4、Google Image Downloader 根据指定词语从Google搜索图片并下载。

5、dir_test.py 检查目录 testdir 是否存在, 如果不存在则创建一个。

6、env_check.py 检查环境变量

7、fileinfo.py 展示文件的元信息

8、folder_size.py 统计当前当前文件夹的大小

9、logs.py 搜索指定目录下所有*.log文件,并压缩以日期格式转储。

10、move_files_over_x_days.py 移动所有满足指定时间日期的文件从源目录到目标文件。

11、nslookup_check.py 打开文件server_list.txt,然后nslookup。

12、osinfo.py 检查系统信息

13、ping_servers.py 根据指定的参数,ping 应用组关联的服务器。

14、ping_subnet.py ping 子网

15、powerdown_startup.py 这个脚本将遍历服务器,如果服务器启动将用gputty登录,如果没有启动将会通知你。

16、puttylogs.py 这个脚本将日志文件归档压缩到置顶目录

17、script_count.py 统计目录下不同脚本

18、 get_youtube_view.py 这个脚本用来统计 youtube 视频的观看次数,有时我也用来统计歌曲的播放次数。 19、 script_listing.py 这个脚本用来遍历指定目录以及子目录下面所有的文件

20、testlines.py 这个脚本用来读取文件并打印100行

21、tweeter.py 用这个脚本发送Twitter

22、serial_scanner.py 端口扫描

23、CountMillionCharacter.py And CountMillionCharacter2.0.py 统计文本字符

24、xkcd_downloader.py 下载最新的XKCD漫画,然后将他们放入comics新文件夹

25、timymodule.py 一个更好的易于使用的timeit模块 26、 calculator.py 使用 Python 的eval()函数实现计算器

27、Google_News.py 使用BeautifulSoup通过新闻链接获取新闻标题

28、cricket_live_score 使用BeautifulSoup提供板球直播分数

29、youtube.py 输入一首歌曲名称然后获取最佳匹配歌曲并播放

30、site_health.py 检查远程服务器的健康情况

31、SimpleStopWatch.py 使用 time 模块简单实现秒表功能