zoukankan      html  css  js  c++  java
  • 用python控制同步hexo脚本

    之前一直在windows下面写hexo博客,但是每次同步需要运行一大堆指令,于是想到用python 写一个脚本来自动同步,用到了os.chdir,因为直接os.system('cd xxx')会自动返回当前路径。

    具体程序如下:

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    # @Time    : 2017/8/10 19:42
    
    import os
    os.chdir((ur'E:项目log'))
    os.system('hexo d -g')
    os.system(ur'git add .')
    os.system("git commit -m 'Updated'")
    os.system('git push origin source')
    print 'done'
    

    然后将启动这个命令设置为简短的命令,类似于alias

    Run the below command in a command prompt to alias ls to run the command dir. The $* on the end are required so that any additional arguments are also passed to the dir command.

    1 doskey ls=dir $*

    The problem with this is that all of your alias commands will be lost when you close the cmd session. To make them persist we need to create a batch file and add the entry to the windows registry.

    Create a new folder in the windows directory called bin and create a new batch file inside it.

    12 C:>mkdir c:windowsinC:>notepad.exe c:windowsindoskey.bat

    Add your entries to the batch file in the below format.

    12345 @echo offdoskey ls=dir $doskey mv=move $doskey cp=copy $doskey cat=type $

    Next, open up regedit.exe and add an entry to the batch file to make the doskey commands permanent for each cmd session.

    1 HKEY_CURRENT_USERSoftwareMicrosoftCommand Processor

    Add a new String Value called AutoRun and set the absolute path in the value of c:windowsindoskey.bat.****

    The doskey.bat file will now be executed before opening a new cmd session which will set all of your alias ready for you to use.

  • 相关阅读:
    记录centos中pptpd server 的配置
    记录IIS7.5的rewrite配置
    duration异常导致的移动端音频无法播放问题
    移动端web开发的几个tips记录
    关于ie8中微软雅黑字体显示的问题
    移动端audio使用的一个注意事项
    关于window.opener的一个小记录
    【翻译】行高的相关计算
    spring 事务管理(编程式)
    CSDN上看到的一篇有关Spring JDBC事务管理的文章(内容比较全)
  • 原文地址:https://www.cnblogs.com/drawon/p/8520744.html
Copyright © 2011-2022 走看看