Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Use Python automatically cleared Android Engineering excess resources     - CentOS6.5 setup Oracle 11gR2 startup (Database)

- Linux set to select the appropriate level of security of the network according to deployment (Linux)

- Four IDS intrusion detection tool under Linux environment (Linux)

- Linux / Windows setup is complete port range (Linux)

- How to make GRub instead of the default Ubuntu software center (Linux)

- RegExp object implements regular match --JavaScript (Programming)

- SQL Server 2008 database synchronization Notes (Database)

- ORA-12154: TNS: could not resolve the connect identifier specified solve (Database)

- Android project using the command to create and install the package (Programming)

- Python Django direct implementation of sql statement (Programming)

- MySQL is configured to access external networks under Ubuntu (Database)

- Linux Tutorial: Open multiple tabs in the GNOME terminal in Ubuntu 15.04 (Linux)

- Use Nginx as a load balancer (Server)

- Mongo-connector integrated MongoD to achieve incremental Solr index (Server)

- Transfer files and permissions from Windows to Linux system by Samba (Linux)

- Linear table with a Java implementation of the iterator (Programming)

- Security matters and practical Linux System (Linux)

- Build your own Python coding environment (Linux)

- Linux terminal interface font color settings (Linux)

- Java multi-threaded in a three way (inheritance, implementation, anonymous inner classes) (Programming)

 
         
  Use Python automatically cleared Android Engineering excess resources
     
  Add Date : 2017-08-31      
         
         
         
  Tips, beginner Python, the development environment is Sublime Text 2, directly Ctrl + B, and other circumstances not tuned. Should almost ^^

#################################################
# Environment: win + python 2.7
# Description: The first time you use the lint analysis will consume a few minutes, please be patient.
# Clean before use projects to ensure that projects under regenerate dex bin,
# For lint analysis. If you want to re-analyze the excess lint
# Resources, the need to delete (2) txt file records, (1) (3) (4) requires
# According to our actual project manually.
# If after clearing resources, engineering missing files and error (rarely
# Case) to try to recover the file by svn.
#################################################
import subprocess
import re
import os
import time
import thread

# (1) project location
projectPath = "D: \ / hao123 \ / code \ / client-android"
# (2) lint output txt file records
txt = "D: \ / hao123_unused_res.txt"
# (3) regular expression, under clear and layout drawable extra jpg / png / xml,
# And exclude sailor_ | wenku_ | zeus_ | bdsocialshare_ | floating_life_ | weather_info_icon_ | anthology_ beginning of the file
regex = re.compile (r "^ res \\ (drawable (-land) (- [xn] [mhlo] (dpi)) |??? layout) \\ ((sailor_ | wenku_ | zeus_ | bdsocialshare_ |?! floating_life_ | weather_info_icon_ | anthology _)) [0-9a-zA-Z _ \.] * \ (jpg |. png | xml) ", re.IGNORECASE)
# (4) lint.bat position
lint = "D: \ / sdk \ / tools \ /lint.bat"

isgotTxt = False
def timer (interval):
    while not isgotTxt:
        print 'Lint is analyzing:% s'% time.ctime ()
        time.sleep (interval)

if not os.path.exists (txt):
    thread.start_new_thread (timer, (5,))
    cmd = lint + '--check "UnusedResources" "' + projectPath + '">' + txt
    p = subprocess.Popen (cmd, shell = True, stdout = subprocess.PIPE, stdin = subprocess.PIPE, stderr = subprocess.PIPE)
    p.wait ()

fobj = open (txt, 'r')
isgotTxt = True
i = 0
j = 0
for line in fobj:
    #print str (i) + ":" + line
    match = regex.match (line)
    if match:
        i = i + 1
        filename = projectPath + "\ /" + match.group (). replace ( '\\', "\\ /")
        try:
            print filename
            os.remove (filename)
            j = j + 1
            print "was deleted!"
        except WindowsError:
            print "is not exists"
            pass

print "Total Unused Resources =" + str (i)
print "Total deleted Resources =" + str (j)
     
         
         
         
  More:      
 
- Hackers is how the invasion and control of Things devices? (Linux)
- Linux environment Duplex (multi-machine) automatic mutual backup scheme (Linux)
- The execution order of Oracle WHERE condition is not from right to left (Database)
- About Git (Linux)
- Learning and Practice (Linux)
- Help you make Git Bisect (Linux)
- Linux shell script debugging (Linux)
- Let Git variety of colors and custom log format output (Linux)
- The Objects in JavaScript (Programming)
- Linux hybrid character device (Linux)
- Linux Command study manual - GPG command (Linux)
- Linux --- manual release system cache (Linux)
- Java memory mechanism Description (Programming)
- Python type way of comparison (Programming)
- CentOS 6.5 Telnet SecureCRT use management tools (Linux)
- Singleton (Linux)
- JavaScript function closures Quick Start (Programming)
- Ubuntu 14.04 LTS compiler installation R Source Code (Linux)
- LinkedList Basic Usage (Programming)
- Linux Firewall Builder shorewall (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.